Notifications
Clear all

[Closed] Point Cache Randomizer

Hey Guys,
I was wondering how I could write a script which would randomize the start frame for all the Point Cache files applied on any object in my scene…

So far all I have is


[color=white][size=1](

try (destroydialog PointCacheRandomizer) catch()

global PointCacheRandomizer

rollout PointCacheRandomizer “Randomize Point Cache”

(

button Pointcache “Point Cache Applier”

on Pointcache pressed do

(

modPanel.addModToSelection (Point_Cache ()) ui:on

)

button randomizer “Randomize It”

on randomizer pressed do

(

$*.modifiers[#Point_Cache].recordStart = random 1 100

)

)

createdialog PointCacheRandomizer width:200 height:100

)

[/color][/size]


Thanks and Regards,
Entrancea

4 Replies

I actually did the same a while ago, it’s quite simple.

 
( 
seed(timestamp())
val=random 0 25
for i in selection do
(
 i.modifiers[#Point_Cache].playbackType = 1
 i.modifiers[#Point_Cache].playbackStart = -val
)
)

Thanks Kameleon,
Also I was wondering like when I select a bunch of objects together and apply any modifier to them it becomes an instanced modifier…But how could I select various objects or atleast a class specific object and apply unique modifiers of the same genre to them?

Also on another note…I tried out the script but the problem seems to be the same…Say if I select a group of objects and then press randomize it randomizes it allright but the same value is applied for all the objects not like seeds or random numbers for each object.

Thanks Dude,
Regards,
Entrancea

 JHN

The pointcache modifier needs to be selected in the modifier panel for the changes to happen…


(
	randMin = 0
	randMax = 25
	playbackType = 1
	
	fn getPointCacheObjects selected:Geometry =
	(
		if selected != undefined then
		(
			pArr = #()
			for o in selected do 
				for m in o.modifiers where classof m == Point_Cache do append pArr #(o,m)
			pArr
		) else
			undefined
	)

	pc = getPointCacheObjects()
	--pc = getPointCacheObjects selected:selection
	
	if pc != undefined then
		for o in pc do															-- Loop 
		(
			select o[1]
			setNeedsRedraw complete:true								-- Force complete redraw for cacheOps to work
			modPanel.setCurrentObject o[2]								-- Set modifier to pc for cacheOps to work

			o[2].playbackType = playbackType
			o[2].recordStart = random randMin randMax
		)
)

To append a unique modifier to a selection use


for i in selection do addModifier i (Point_Cache())

To select objects of specific classes look for the classof and superclassof methods in the helpfile. Also take a look at my getPointCacheObjects function above, maybe it gives you a start.

Goodluck,
-Johan

Hey, sorry I just realized I gave you an older version of my script. I used it in a very specific case where I didn’t need random values. Try using JHN script instead! Good luck.