Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / how to find key value and key time on kFBPT_double custom property?
  RSS 2.0 ATOM  

how to find key value and key time on kFBPT_double custom property?
Rate this thread
 
63829
 
Permlink of this thread  
avatar
  • Newt
  • Posted: 24 January 2012 07:03 AM
  • Location: Atlanta, GA
  • Total Posts: 12
  • Joined: 15 January 2009 04:34 PM

I’m new to python and I would like to know how i can find and read all key value and key time of each fcurve of all kFBPT_double custom properties from a marker.

I try to dig into the doc but it’s kind of difficult to understand for me.

If any one can help me, it would be great.



Replies: 0
avatar
  • Newt
  • Posted: 25 January 2012 07:35 AM

I was trying as well to find all custom properties from a marker and print each custom property name but I just find the function to find the custom property by name in the doc…
Any advice?

Thanks



Replies: 0
avatar
  • _stev_
  • Posted: 26 January 2012 08:16 AM

Here’s a little example that should help.

from pyfbsdk import *

nullObj FBFindModelByName('Null')
prop nullObj.PropertyList.Find('CustomKeyedNumber')
# Get the animation node of a property
animNode prop.GetAnimationNode()
# The FCurve of the node has the key data
for k in animNode.FCurve.Keys:
   
# Each key has attributes like Time, Value, Bias, Continuity, etc.
   
print 'Key at time %s = %.3f' % (k.Time.GetTimeString(), k.Value)

Stev



Replies: 0
avatar
  • Newt
  • Posted: 26 January 2012 08:44 AM

Thanks a lot.
I understand now how to read and store key value and key time of a known custom property.
My problem is that I’m trying to read data from an FBX file that contains markers with lots of custom properties and I would like to find all these custom properties. As I don’t know any of these custom property names, how can I find them and get these names?
My goal is to automatically find custom property and store names and keys (if there are keys) whatever is the name of the custom property.

Thanks



Replies: 0
avatar
  • _stev_
  • Posted: 26 January 2012 08:55 AM

I think something like this should work:

from pyfbsdk import *

nullObj FBFindModelByName('Null')
# Check all properties
for prop in nullObj.PropertyList:
   
# If the property isn't a user prop, skip it
   
if not prop.IsUserProperty(): continue

   print 
'Showing Keys for Property: %s' prop.Name

   
# Get the animation node of a property
   
animNode prop.GetAnimationNode()
   
# The FCurve of the node has the key data
   
for k in animNode.FCurve.Keys:
      
# Each key has attributes like Time, Value, Bias, Continuity, etc.
      
print 'Key at time %s = %.3f' % (k.Time.GetTimeString(), k.Value)


Replies: 0
avatar
  • Newt
  • Posted: 27 January 2012 01:45 AM

Thanks _stev_.
This is exactly what I was looking for.
Now I understand how I can check if a property isn’t a custom property.
I just need to add a test for any custom property type that doesn’t have a direct animation node like Color where you have to go to r g b or text that don’t have any animation. I will see if I can succeed and post the result.

Thanks again!



Replies: 0