MotionBuilder Forum
Welcome to Autodesk’s MotionBuilder Forums. Share your knowledge, ask questions, and explore popular MotionBuilder topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to change takes order?

7 REPLIES 7
Reply
Message 1 of 8
jps
Advocate
1330 Views, 7 Replies

How to change takes order?

Is there a way in Python to change the order of takes?
Thanks
7 REPLIES 7
Message 2 of 8
cmot
in reply to: jps

I only have 2012 to work with, so I'm not sure if this is implemented in 2013 or 14, motionbuilder won't let you reorder the takes list directly. Trying to use any list modifying functions that python has other than just adding to the end of the list gets you a NotImplementedError. Though motionbuilder might have a higher level method for changing the Takes list that I just haven't found yet.

That said, there is a way to work around it. Though I don't think I would try it in a scene with a lot of takes and a lot of elements in it.

You can specify a new order for the takes, then have motionbuilder jump to each of those takes and copy it, so it gets added to the end. Now you've got double the takes, with the copies being in the new order you want. Then you can loop through and delete the first element the same number of times as original number of takes you had.

Here's an example:

from pyfbsdk import *

takes = FBSystem().Scene.Takes
numTakes = len(takes)

#new order for takes, this will swap the 2nd and 3rd positions
newOrder =

#copy takes in the new order you want them
for index in newOrder:
FBSystem().CurrentTake = takes
FBSystem().CurrentTake.CopyTake("%s_temp" % takes.Name)

#delete the old takes
for x in range(0,numTakes):
takes.FBDelete()

#remove the "_temp" from the take names
for take in takes:
take.Name = take.Name
Message 3 of 8
jps
Advocate
in reply to: jps

Thanks a lot CMOT.
I've tried this solution but I have a problem when I copy the take. This function doesn't copy the custom properties associated to the take. I'm working with MB 2014 and even the UI version of copy/duplicate take has this bug. Duplicating markers, bones or nulls is fine but not takes.
My problem is I'm using all these custom properties for other scripts and in some relations constraints. I can't easily duplicate the take, recreate all the custom properties, relink all the custom properties in all my relations, that's why I wanted to rearrange the order only.
Message 4 of 8
HyagoOliveira
in reply to: jps

In the Navigator Windos, open Takes section. There, you'll be able to rename all takes like any other component. Also, you may be able to rearrange take's orthers too.

Message 5 of 8
d.pajda
in reply to: jps

I'm also interested in this, maybe someone has idea how to do this? 🙂

I'm trying to make Takes manager tool, and would be great if python would also allow to change order of takes. 

Message 6 of 8
vdebaie
in reply to: d.pajda

re-indexing takes seems to be something MotionBuilder allows the user to do only through manually sorting via the Navigator.

 

some ways you could try to change this:

 

Duplicate takes and delete the originals:

- make a list of all takes

- duplicate them is the specific order you want them to be in

- delete the original takes that are in your list

 

** as for the take properties, you could recreate those properties via script on to each take before deleting the original takes

 

You could try to save out takes into different files and then merge them in the order you want them- This would be a very long process compared to duplicating and recreating the properties. the time is would take to save out each take as their own file and then create a new scene and merge each file in one at a time in the order you want would be VERY VERY timely.

 

 

 

 

Message 7 of 8
lee.dunham
in reply to: jps

Answered on another forum so posting here for visibility in future.

The easiest option IMO is to disconnect and reconnect the takes from the FBScene in the desired order. You may need to force some evaluations to ensure all relevant callbacks are made.

Message 8 of 8
damian.pajda
in reply to: lee.dunham

Wow, thanks for this solution! I just tried it and it works perfectly.

This simple solution for replacing take to the end of list works great: 

 

take.DisconnectDst(self.FBScene)
take.ConnectDst(self.FBScene) 

 

Do you have some more experience with this? Is it stable and safe for use "in production" ? 🙂 

BTW. I also found that it is possible to just narrow down the search to only Takes list, not the whole Scene, which seems a bit more safe and works even faster in bigger scenes...

 

TakesList = FBSystem().Scene.Takes[0].GetDst(1)
take.DisconnectDst(TakesList)
take.ConnectDst(TakesList) 

 

In this case FBSystem().Scene.Takes[0].GetDst(1) give me pointer to Takes List plug, so I can reorder takes components only in this smaller part of scene, not whole scene.

 

Thanks again for this idea, I would never figured that out. FBPlug was black magic to me 😄 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report