ScriptSpot

Forum topic · General Scripting

annoying script freezing

By Daniel Wichterich · 2012-05-21

Description

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 (7)

simulation

barigazy · 2012-05-21

Are you use *simulateLocal*?

mesh to be on world origin constantly

barigazy · 2012-05-21


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

Daniel Wichterich · 2012-05-21

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 · 2012-05-21

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

Daniel Wichterich · 2012-05-21

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 · 2012-05-21

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.

Try this

barigazy · 2012-05-21


(
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]
)
)
)
)