Execute python script on selected takes

Execute python script on selected takes

Anonymous
Not applicable
1,861 Views
5 Replies
Message 1 of 6

Execute python script on selected takes

Anonymous
Not applicable

Hello all,

 

Does anyone know how to access the selected takes via python script?  I have a script I wrote that I would only want to run on selected takes.  Ideally I would like to find the selected takes and iterate over them.  Conversely, I would settle for a way to manually run a script itself only on the selected takes.  Any info would be appreciated.  Thanks!!!

0 Likes
Accepted solutions (1)
1,862 Views
5 Replies
Replies (5)
Message 2 of 6

brissef2
Autodesk
Autodesk
Accepted solution

Hi Senorsean32,

 

Here a sample script to iterate over all the selected takes, and prints its name:

 

for aTake in FBSystem().Scene.Takes:
    if aTake.Selected:
        print aTake.Name

Please let me know if it helps.

 

Best regards,

Francis

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks Francis. That totally helped.  I actually solved it before you responded to me in a less efficient, newb way haha.  I iterated through the components looking for the class_name to be FBTake.  Your solution is much cleaner.  I changed my code with it and it works great. 

 

Thanks a lot for the incredibly quick reply too. I'll be sure to keep this forum in mind when I hit the python-mobu wall again in the future 🙂

 

-Sean

0 Likes
Message 4 of 6

vdebaie
Advocate
Advocate

is there a way to have that sample script print an error if no takes are selected?

 

for aTake in FBSystem().Scene.Takes:
    if aTake.Selected:
        print aTake.Name
else:
print "no take selected"

this works, but prints it for every take in the scene. lol, thanks. :)

0 Likes
Message 5 of 6

brissef2
Autodesk
Autodesk

HI @vdebaie,

 

Here you go:

 

takeSelected = False

for aTake in FBSystem().Scene.Takes:
    if aTake.Selected:
        print aTake.Name
        takeSelected = True


if not takeSelected:
        print "no take selected"

Best regards,

Francis

0 Likes
Message 6 of 6

vdebaie
Advocate
Advocate

Great! thanks!!!!Smiley Very Happy

0 Likes