PDA

View Full Version : How to make objects appear for only 1 frame in pymel


JustAnotherGuy
01-22-2013, 04:12 AM
Hi, we're doing pymel for my uni course, i've only started last week so I'm still very new to it and need a little help (so please keep it simple lol, also skip past the pic to cut to the chase)


Basically, I've done a script which will randomly generate a city like object which will let the user pick some values (size, subdivs etc), then randomly generates the rest (didn't mean it to be a city, but it just kinda ended up looking a little like one)


There is one value which is randomly set, which will either give a lot of simple square buildings at the lower end, and a lot of larger more unusual shaped buildings when it's a lot higher, unfortunately it's just a single variable so it applies to the entire object no matter how detailed it is

Here's an example of it anyway, I think the value is about 3/4 from the highest it could be
http://i50.tinypic.com/106dcw1.jpg

Anyway, I would like to add in something which will run the code for a number of frames, so a new object would be generated just for each frame, but so it'll only appear in that one frame, and then delete/hide itself afterwards

Any help would be appreciated, the whole script is contained in a function so I just need the last bit doing now :)

Here's my half finished failed attempt -

for i in range( 1, 2 ):
pm.currentTime( i, edit = True)
createObject( smooth, oneLayer, twoLayers, threeLayers, fourLayers, pl_subdivs, pl_size, pl_subdivsize, vertDeleteChance)

Cheers :)

Koochy
01-28-2013, 05:16 AM
I'm guessing you want the city, or collection of nodes to appear to generate in front of you? Why not just key the generated objects visibility after each loop? Assuming your function returns the new object:

for i in range( 1, 2 ):
pm.currentTime( i, edit = True, update = True)
newObject=createObject( smooth, oneLayer, twoLayers, threeLayers, fourLayers, pl_subdivs, pl_size, pl_subdivsize, vertDeleteChance)
pm.setKeyframe(newObject.v, time=i, value=1)
pm.setKeyframe(newObject.v, time=i+1, value=0)

JustAnotherGuy
01-28-2013, 11:48 PM
Ahh thanks a lot :D I kinda realise i should have posted a little more code aha, anyways with a bit of moving around and renaming stuff it started working, so yep, cheers for that ;D

CGTalk Moderation
01-28-2013, 11:48 PM
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.