Message 1 of 5
Not applicable
12-05-2013
04:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey guys, very new scripting/python and was hoping to get some help.
Ive been trying to make a simple window that holds a few buttons with commonly used assets.
First asset Im trying to tackle is having a button add a parent contraint.
I can get the window to pop up with my button and just cant seen to figure out how to call the "CreateCons" function using the button. Pasting my code below.
whenI run it I currently get a "TypeError: 'NoneType' object is not callable"
If anyone can steer me in the right direction, I would appreciate it.
Thanks in adavance.
from pyfbsdk import *
from pyfbsdk_additions import *
#------------------Add Constraint---------------------------------
def CreateCons (Name, Type, Active):
myManager = FBConstraintManager()
myCons = myManager.TypeCreateConstraint(Type)
myCons.Name = Name
myCons.Active = Active
#--------------------------------------------------------------------------------
def PopulateLayout(mainLyt):
x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
y = FBAddRegionParam(5,FBAttachType.kFBAttachTop,"")
w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
mainLyt.AddRegion("main","main", x, y, w, h)
lyt = FBHBoxLayout()
mainLyt.SetControl("main",lyt)
b = FBButton()
b.Caption = "add constraint"
b.Style = FBButtonStyle.kFB2States
b.Look = FBButtonLook.kFBLookColorChange
b.Justify = FBTextJustify.kFBTextJustifyCenter
b.SetStateColor(FBButtonState.kFBButtonState0,FBColor(0.20, 0.0, 0.45))
b.SetStateColor(FBButtonState.kFBButtonState1,FBColor(0.20, 0.0, 0.45))
lyt.Add(b,90)
b.OnClick.Add(CreateCons("gunConstraint", 5, True))
def CreateTool():
# Tool creation will serve as the hub for all other controls
t = FBCreateUniqueTool("Tools")
t.StartSizeX = 305
t.StartSizeY = 70
PopulateLayout(t)
ShowTool(t)
CreateTool()
Solved! Go to Solution.