PDA

View Full Version : python constraints


SebO
06-28-2010, 06:23 PM
Hi,

OK, I’m learning this python thing. I’ve created a parentconstraint, activated and so on, but now i need to get the objects that i want to constrain in there. How do I do that???

here’s what i got so far.

from pyfbsdk import *

def CreateCons (Name, Type, Active):
myManager = FBConstraintManager()
myCons = myManager.TypeCreateConstraint(Type)
myCons.Name = Name
myCons.Active = Active


CreateCons("Test", 3, True)

Using MB 2010

Thanks

scottiedoo
06-29-2010, 04:14 AM
In the python docs under FBConstraint class reference. Look at the ReferenceAdd method.

You will need to pass it the group index and the FBModel you want to add.

myCons.ReferenceAdd(0, ChildModel)
myCons.ReferenceAdd(1, ParentObject)


Shameless plug, take a look at my PyMoBu project which easily allows you to get and set these type of constraint settings with ease: http://code.google.com/p/pymobu/

Hope that helps and good luck,
Scott

SebO
06-29-2010, 08:28 AM
It worked, thanks, now I also need it to snap, so that the object keeps the offset. tryed the FBAction snap but i cant semms to make it work.

SebO
06-29-2010, 03:27 PM
found out. remove the .active... thanks

CGTalk Moderation
06-29-2010, 03:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.