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: 

I want to store the selected items to the folder

4 REPLIES 4
Reply
Message 1 of 5
pesimiti
497 Views, 4 Replies

I want to store the selected items to the folder

To store to one of the folders in the state in which you select more than one light
What should I do?

This way to you has created a tool, not only one of the light storage,
It does not result in the desired street.

 

 

from pyfbsdk import *

 

#light folder create#

light = FBLight("test_light")

light_folder = FBFolder("light folder", light)

 

#selected lights#

for i in FBSystem().Scene.Lights:

i.Selected = True

 

models = FBModelList()

FBGetSelectedModels(models)

 

for i in models:

print i.Name

 

#appenf light_folder#

light_folder.Items.append(i)

 

print i.Name

4 REPLIES 4
Message 2 of 5
bujinkan02
in reply to: pesimiti

Hi, Pesimiti
I'd don't get exactly what you are trying to do. Can you describe the result you expect ?
Thanks
Message 3 of 5
pesimiti
in reply to: bujinkan02

Thank you so much for your reply!

 

I found out the problem, but this (bellow) is what I wanted to say.

 

------------------------------------------------------------------------------------------------------

How should I write a python script that makes selected nodes get stored into one folder?

Even though I thought I made the correct script, when I executed it, only one node went into the folder.

What do you think is wrong with my script?

------------------------------------------------------------------------------------------------------

 

The problem was that I didn't include an "indent (space)".

 

I just started learning python but I hope I can get better at it soon.

 

Thank you.

Pesimiti.

 

Message 4 of 5
bujinkan02
in reply to: pesimiti

Hi,

 

You probably missed something with the indentation, try something like that :

 

from pyfbsdk import *

#light folder create#
lightA = FBLight("test_lightA")
lightB = FBLight("test_lightB")
lightC = FBLight("test_lightC")

light_folder = FBFolder("light folder", lightA)

#selected lights#
for i in FBSystem().Scene.Lights:
    i.Selected = True
    
#Create the model list
models = FBModelList()   
FBGetSelectedModels(models)
    
for i in models:
    #appenf light_folder#
    #If the light is not already in the folder, we add it
    if i not in light_folder.Items:
        light_folder.Items.append(i)
    print i.Name

 

I've just add an if statement to check if the light is already in folder or not to avoid a 'duplication' error message.

 

Keep it up !

Cheers

 

Message 5 of 5
pesimiti
in reply to: bujinkan02

Thank you so much for your advice!!

 

The duplication error was exactly the next trouble I was having.

 

All my problems for this time has been solved.

 

Thank you again and I will keep studying!

 

Best regards,

Pesimiti

 

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

Post to forums  

Autodesk Design & Make Report