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 / parent constraint
  RSS 2.0 ATOM  

parent constraint
Rate this thread
 
31401
 
Permlink of this thread   Subscribe to this thread
avatar
  • Total Posts: 3
  • Joined: 23 March 2009 11:45 AM

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…



Replies: 0
avatar

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.



Replies: 0
avatar
  • AndyPC
  • Posted: 29 June 2009 01:10 PM

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 :)



Replies: 0
avatar
  • Seb123
  • Posted: 26 August 2010 04:32 AM

The way it works for me is to turn off the constraint and use snap to activate it again

c.Active False
c
.Snap ()


Replies: 1
/img/forum/dark/default_avatar.png

I believe activating in 7.5 inst as straight forward as that. The way i did it was.

c.PropertyList.Find("Active").Data = True

Author: Beat1823

Replied: 26 August 2010 04:52 AM  




   
  Settings Choose Theme color: