View Full Version : Hide-unhide objects sequence

09 September 2010, 04:41 PM
Hi i'm new on scripting and i'm trying to create a script on phyton to show just one object on each frame:

Thats what i have so far:

for i in range(10): #Number of frames
Application.SetKey("cube-%d.visibility.rendvis" %(i+1), (i+2), 0, "")
Application.SetKey("cube-%d.visibility.rendvis" %(i+1), (i+1), 1,"")
Application.SetKey("cube-%d.visibility.rendvis" %(i+1), (i), 0, "")
Application.SetKey("cube-%d.visibility.viewvis" %(i+1), (i+2), 0, "")
Application.SetKey("cube-%d.visibility.viewvis" %(i+1), (i+1), 1,"")
Application.SetKey("cube-%d.visibility.viewvis" %(i+1), (i), 0, "")

print "Finished"

Could anyone give me some advice?

09 September 2010, 09:04 AM
A couple more details wouldn't go amiss :)
Do you have N objects and you wish only one to be showing for each frame across as many frames as you have objects? Or something else?

Assuming the above, and that the order of selection is what you want for the showing/not showing, try something like this:

startFrame = 10

for objIndex, eachObject in enumerate(Application.Selection):
parViewVis = eachObject.Properties("visibility").Parameters("viewvis")
Application.SaveKey(parViewVis, startFrame + objIndex -1 , False)
Application.SaveKey(parViewVis, startFrame + objIndex, True)
Application.SaveKey(parViewVis, startFrame + objIndex +1 , False)

Not 100% ideal as there's better object oriented options to create animation, but at least this should read easily enough for a neophyte.

CGTalk Moderation
09 September 2010, 09:04 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.