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: 

Mobu: choose character(and rember it) from a dropdown list

1 REPLY 1
Reply
Message 1 of 2
Anonymous
349 Views, 1 Reply

Mobu: choose character(and rember it) from a dropdown list

Hey,
I am new to scripting in python for MotionBuilder, and I am having some difficulty with a script that needs to allow the user to choose a selected character from a dropdown list, and plot the animation.
I managed to create the window and the dropdown list with all the characters in the scene, I just need to find out how to remeber the selected characters- preferably when clicking the ok button.

    print control.Items #prints the selected characters on selection
varTest = 0
for x in control.Items:
if x.IsSelected(varTest):
x.Items.append(chararacterList.Name)


or #prefer this one

def ClosePopupCallback(control, event):
characterList=[]
for x in Items:
if x.selected (True):
x.Items.append(chararacterList.Name)
CloseTool(t)


Any ideas? Thank you!
1 REPLY 1
Message 2 of 2
castortroy182
in reply to: Anonymous

Hi,

well your suggestions were the first ones that came into my mind when I had the same problem. 😉

In some of the example scripts provided by autodesk they had a totally different approach by setting the actual tool to global:

def CreateTool():
global tool

tool = CreateUniqueTool("Property Example")
tool.StartSizeX = 400
tool.StartSizeY = 200
PopulateLayout(tool)
ShowTool(tool)
CreateTool()


Later in the PopulateLayout-Function you can access this tool very easily. Here shown in the autodesk example script:


...
def PopulateLayout(mainLyt):
x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
h = FBAddRegionParam(25,FBAttachType.kFBAttachBottom,"")
mainLyt.AddRegion("main","main", x, y, w, h)
vlyt = VBoxLayout()
mainLyt.SetControl("main",vlyt)

l = FBLabel()
l.Caption = "Drag and drop a model into the container. Double click to clear."
vlyt.Add(l,30)

tool.model = None
tool.container = FBContainer()
tool.container.OnDragAndDrop.Add(EventContainerDragAndDrop)
tool.container.OnDblClick.Add(EventContainerDblClick)
vlyt.Add(tool.container,30)
...


In your own code just create a list and make sure it is added to the tool like in the first line below:


...
tool.myDropDownList = FBList()
tool.myDropDownList.Style = FBListStyle.kFBDropDownList
for obj in myList:
tool.myDropDownList.Items.append(obj.Name)
lyt.Add(tool.myDropDownList, 20) #add line 2 with 20 pixels from the top
...


myList contains the actual list that will be shown in the dropdown-list, e.g. myList=.

After you set up your button(FBButton()) in its callback-function you can easily access the items in the list with tool.<<your list>>:

def ButtonCallback(control, event):
myList = tool.myDropDownList.Items
print tool.myDropDownList.Items+" is ready to be processed"
# put the rest of the script here


Cheers,

Chris

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

Post to forums  

Autodesk Design & Make Report