annoying script freezing

Hi, I am working on a simple script which does work fine but freezes ramdomly for several minutes. The script "stabilizes" an animated mesh to be on world origin constantly. Any ideas on that? Would be great!

undo off
(
cui.commandPanelOpen = false
myOffset = #()
myLastFrame = animationrange.end as integer
for i = 0 to myLastFrame do
(
sliderTime = i
myOffset[i+1] = $.center
)
ResetXForm $
modPanel.addModToSelection (XForm ()) ui:off
set animate on
for j = 0 to myLastFrame do
(
sliderTime = j
$.modifiers[#XForm].Gizmo.position = -myOffset[j+1]
)
set animate off
cui.commandPanelOpen = true
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

simulation

Are you use *simulateLocal*?

bga

barigazy's picture

mesh to be on world origin constantly

$[3][1].track = position_script()
$[3][1].track.script = "[0,0,0]"

bga

Daniel Wichterich's picture

thanks a lot. but this does

thanks a lot. but this does freeze max too. on the last frame, when the script should be done, max hangs for 5-10 minutes doing nothing.

i suspect my mesh to be the problem somehow, it is a cloth simulation.

barigazy's picture

Are you try with position

Are you try with position script?
Send me a test scene and explain me what do you want to achive.
Maybe is there better solution for this problem

bga

Daniel Wichterich's picture

i can prepare something

i can prepare something tonight and send it to you.

imagine a mesh which is moving away from world origin. the pivot stays on world origin, the mesh does not. therefor the position script does not work.

my script "stabilizes" that motion to keep the mesh centered. problem is it freezes for some reason

barigazy's picture

It's not easy task.

It's not easy task.
They would help if you add position constraint and use point helper
(at origin) as target.But i think that simulation break any mesh link with other objects.

bga

barigazy's picture

Try this

(
if getCommandPanelTaskMode() != #create do setCommandPanelTaskMode mode:#create
undo off
(
	myOffset = #()
	local obj = $
	myLastFrame = animationrange.end as integer
	for i = 0 to myLastFrame do
	(
		sliderTime = i
		myOffset[i+1] = obj.center
	)
	ResetXForm obj
	addmodifier obj (XForm ())
	local objmod = obj.modifiers[1]
	with animate on
	(
		for j = 0 to myLastFrame do
		(
			sliderTime = j
			objmod.gizmo.position = -myOffset[j+1]
		)
	)
)
)

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.