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 / Getting a position constraint's translation value
  RSS 2.0 ATOM  

Getting a position constraint's translation value
Rate this thread
 
46836
 
Permlink of this thread   Subscribe to this thread
avatar
  • Trizoy
  • Posted: 01 September 2010 01:13 PM
  • Total Posts: 6
  • Joined: 23 August 2010 05:58 PM

Hey,

In the asset browser, I can see that my position constraint has a property called ‘Translation’; this is the value I want to get with my script.

I’ve tried going about this in much the same way that I would go about getting the translation value for an FBCamera object (for example), but I am always returned an error:

from pyfbsdk import *

allConstraints=FBSystem().Scene.Constraints
for constraintLoop in allConstraints:
    if 
constraintLoop.Name == "My Position Constraint":
        print 
"Found your position constraint..."
        
yourConstraint constraintLoop
    
positionConstraintOffset 
yourConstraint.Translation

Im sure there is a way to get this value, any help would be much appreciated!

Thanks!



Replies: 0
avatar
  • senglert
  • Posted: 01 September 2010 03:05 PM

Most attributes are hidden in the property list. There is no “Translation” object attribute for FBConstraint types since not all constraints have this.

So to find the information you are looking for you would simply find it in the property list:

from pyfbsdk import *

allConstraints=FBSystem().Scene.Constraints
for constraintLoop in allConstraints:
    if 
constraintLoop.Name == "My Position Constraint":
        print 
"Found your position constraint..."
        
yourConstraint constraintLoop
    
positionConstraintOffset 
yourConstraint.PropertyList.Find("Translation").Data

This will return you a FBVector3d object.

Suggestion… break out of the loop once you found the correct constraint to conserve time

Cheers,
Scott



Replies: 0
avatar
  • Trizoy
  • Posted: 01 September 2010 03:39 PM

Awesome :)

Thanks Scott!



Replies: 0




   
  Settings Choose Theme color: