Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / [SOLVED] How to get gui buttons to run script???
  RSS 2.0 ATOM  

[SOLVED] How to get gui buttons to run script???
Rate this thread
 
46849
 
Permlink of this thread   Subscribe to this thread
avatar
  • Seb123
  • Posted: 01 September 2010 11:26 PM
  • Total Posts: 92
  • Joined: 05 November 2009 10:41 AM

I got the gui working and some scripts i want to run. This is just a test, but i can’t figure out how to get that working. I’ve been searching the web but I can’t seem to find anything about that. Please help…

from pyfbsdk import *
from pyfbsdk_additions import *

def create ():
    
cube FBModelCube ("Cube")
    
cube.Show True


def delete 
():
    
model FBFindModelByName ("Cube")
    
model.FBDelete ()





def PopulateLayout(mainLyt):
    
FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
    
FBAddRegionParam(5,FBAttachType.kFBAttachTop,"")
    
FBAddRegionParam(5,FBAttachType.kFBAttachRight,"")
    
FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
    
mainLyt.AddRegion("main","main"xywh)
    
    
lyt HBoxLayout()
    
mainLyt.SetControl("main",lyt)
    
    
FBButton()
    
b.Caption "Create"
    
lyt.Add(b,80height=30)
    
    
FBButton()
    
b.Caption "Delete"
    
lyt.Add(b,80space=5,height=30)

def CreateTool():
    
CreateUniqueTool("Ghost Tool")
    
t.StartSizeX 190 
    t
.StartSizeY 75

    PopulateLayout
(t)
    
ShowTool(t)

CreateTool()


Replies: 0
avatar
  • Seb123
  • Posted: 02 September 2010 12:21 AM

Sorry for bugging you guys. I found out once again.
here it is if anyone needs help.

from pyfbsdk import *
from pyfbsdk_additions import *

def create ():
    
cube FBModelCube ("Cube")
    
cube.Show True


def delete 
():
    
model FBFindModelByName ("Cube")
    
model.FBDelete ()

create_mappings {
    
"Create" lambda control Noneevent None create (),
    
"Delete" lambda control Noneevent None delete ()
}


def PopulateLayout
(mainLyt):
    
FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
    
FBAddRegionParam(5,FBAttachType.kFBAttachTop,"")
    
FBAddRegionParam(5,FBAttachType.kFBAttachRight,"")
    
FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
    
mainLyt.AddRegion("main","main"xywh)
    
    
lyt HBoxLayout()
    
mainLyt.SetControl("main",lyt)
    
    for 
mappingfunc in create_mappings.iteritems():
        
FBButton()
        
b.Caption mapping
        lyt
.Add(b,80height=30)
        
b.OnClick.Add(func)
    



def CreateTool():
    
CreateUniqueTool("box Tool")
    
t.StartSizeX 190 
    t
.StartSizeY 75

    PopulateLayout
(t)
    
ShowTool(t)

CreateTool()


Replies: 0




   
  Settings Choose Theme color: