|
Hi, i am trying to parent constrain a mesh object to a joint in Motion Builder 7.5 using python. I am still very new to python programming and would really appreciate any guidance at all.
Thank you…
|
|
|
|
Hi,
Here’s an example for creating a Parent/Child constraint and parent the elements in it :
from pyfbsdk import *
lCube = FBModelCube("My Cube")
lCube.Visible=True
lCube.Show=True
lMarker = FBModelMarker("My Marker")
lMarker.Visible=True
lMarker.Show=True
lConstraint = FBConstraintManager().TypeCreateConstraint (4)
FBSystem().Scene.Constraints.append(lConstraint)
lConstraint.ReferenceAdd (0,lMarker)
lConstraint.ReferenceAdd (1,lCube)
#lConstraint.Snap = ???
lConstraint.Active = True
There’s only one problem, the Snap function is apparently a FBAction, but I can’t find any infos on that…
Anyway, hope it helps.
|
|
|
|
Hi, regarding ‘Snap’, this is probably not the correct way to use it, but after along time messing around with it I finally got a working solution
cnstPC = lMgr.TypeCreateConstraint(4)
cnstPC.Name = “NullPC”
cnstPC.ReferenceAdd(0, null1)
cnstPC.ReferenceAdd(1, null2)
cnstPC.Active = True #this will move null1(constrained) to null2(source)
null1.Translation = FBVector3d(x,y,z) #apply the trans offset you require / or SetVector
null1.Rotation = FBVector3d(x,y,z) #and rot offset you require / or SetVector
cnstPC.Snap() #then snap (it is a function it seems)
HTH, if anyone finds another (proper?) way, do share :)
|
|
|
|
The way it works for me is to turn off the constraint and use snap to activate it again
c.Active = False
c.Snap ()
|
|
|