You are here: Homepage /  Tutorials & Tips /  Tips / Adding Custom Properties
Adding Custom Properties
Posted: Oct 31, 2006
Published by: the area
Homepage: none
Software: Autodesk MotionBuilder

## This is a sample script for beginners for how you might add custom properties to a group of selected models.

## Tested in MB 7.5 Ext1

## Brett Ineson

from pyfbsdk import FBVector3d, FBModelList, FBGetSelectedModels, FBComponent, FBProperty, FBPropertyType

from pyfbsdk import FBPropertyAnimatable, FBPropertyManager, FBMessageBox, FBProgress, FBColor

# Create an empty FBModelList object.

lModels = FBModelList()

# Obtain the list of selected models.


# List of Properties to create

lProperty = (('My Double ', FBPropertyType.kFBPT_double, 'Number',True, True, None),

('My Vector3D ', FBPropertyType.kFBPT_Vector3D, 'Vector', True, True, None),

('My Colour ', FBPropertyType.kFBPT_ColorRGB, 'Vector', True, True, None),

('My Colour with Alpha ', FBPropertyType.kFBPT_ColorRGBA, 'Vector', True, True, None),

('My Action ', FBPropertyType.kFBPT_Action, 'Number', True, True, None),

('My Bool ', FBPropertyType.kFBPT_bool, 'Number', True, True, None),

('My Integer ', FBPropertyType.kFBPT_int, 'Number', True, True, None))

# Explanation of property syntax

# Parameters:

# pName - The name of the property.

# pType - Type of the property see enum FBPropertyType.

# pDataType - DataType of the property is a text define in ANIMATIONNODE_TYPE_??? in fbdata.h.

# pAnimatable - To specify if the property can be animated.

# pIsUser - To specify if the property is available as a custom property or dynamic and attached to the object.

# pReferenceSource - Use that param to specify the property that a reference refer to.

# check if there is a selection

if len( lModels ) == 0:

FBMessageBox( "Message", "Nothing selected", "OK", None, None )


# Create a FBProgress object and set default values for the caption and text.

lFbp = FBProgress()


lFbp.Text = "yay !"

lCount = 0.0

# Create custom properties

for x in lModels:

for ( pName, pType, pDataType,pAnimatable, pIsUser, pReferenceSource ) in lProperty:

x.PropertyCreate( pName, pType, pDataType,pAnimatable, pIsUser, pReferenceSource )

# set values for 'My Double'

lProp = x.PropertyList.Find('My Double ')



lProp.Data = 0

# SetAnimated exposes the property to the relations constraint


# set values for 'My Vector3D'

lProp = x.PropertyList.Find('My Vector3D ')

lVector = FBVector3d(90,20,-70)

lProp.Data = lVector


# set values for 'My Colour '

lProp = x.PropertyList.Find('My Colour ')

lColour = FBColor(0,0,255)

lProp.Data = lColour


# set values for 'My Colour with Alpha '

lProp = x.PropertyList.Find('My Colour with Alpha ')

lColour = FBColor(0,255,0,50)

lProp.Data = lColour


# set values for 'My Action '

lProp = x.PropertyList.Find('My Action ')


# set values for 'My Bool '

lProp = x.PropertyList.Find('My Bool ')

lProp.Data = True


# set values for 'My Integer '

lProp = x.PropertyList.Find('My Integer ')



lProp.Data = 0


lCount += 1

lVal = lCount / len(lModels) * 100

lFbp.Percent = int(lVal)

# We must call FBDelete when the FBProgress object is no longer needed.


# Cleanup of local objects.

del( lModels, lProp, lProperty, lFbp, lVal, lCount )

# Cleanup of imported modules.

del( FBVector3d, FBModelList, FBGetSelectedModels, FBComponent, FBProperty, FBPropertyType )

del( FBPropertyAnimatable, FBPropertyManager, FBMessageBox, FBProgress,FBColor )

In order to post any comments, you must be logged in!
Newest users comments View All 12 Comments
Posted by Salem150 on Jan 09, 2012 at 05:21 AM
maybe he mean a scripts beginners?
anyway for who understand this, this well help him/her
Posted by cowboy on Jan 02, 2012 at 02:11 PM
Hmmm...although a bit harsh.....must agree with ITTY BITTY. I am a long time MB user....but a newbie at scripting. That was my thought as well......this is NOT for beginners. Really does not help learning scripting.
Posted by ITTY BITTY on Oct 22, 2011 at 02:22 AM
This is not for beginners....It seems almost like reading another language. I think you should leave the tutorials to the pros. A waste of time for a beginner.......did you ever stop to think that if it was for a beginner you shouldn't have used action script. Thanks for nothing!!!!!!!!