MotionBuilder Forum
Welcome to Autodesk’s MotionBuilder Forums. Share your knowledge, ask questions, and explore popular MotionBuilder topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Attempting to Connect Custom Properties in Relation Constraint causes Crash in MoBu...?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
1629 Views, 2 Replies

Attempting to Connect Custom Properties in Relation Constraint causes Crash in MoBu...?

Hey...

I have a quite complicated Relation Constraint that I want to automate the creation of that affects different movements of a facial rig... However, although I know how to create Custom Properties - and create Relation Constraints, connections etc... I have so far not had to connect Custom Properties...

Manually I have to set the Custom Property to 'animatable' by toggling the 'A' button on the right of the slider to view the Property in the Relation Window before I can create a connection... How do I replicate this in Python...? Maybe this is all the problem is...?

The code below is something I have borrowed from this site for testing (thanks to whoever it was I got it from...!)

This works for connecting existing Properties...



from pyfbsdk import *

################################

def FindAnimationNode( pParent, pName ):
lResult = None
for lNode in pParent.Nodes:
if lNode.Name == pName:
lResult = lNode
break
return lResult

################################

def createSourceBox (sourceObj):

sourceBox = lConstraintRelation.SetAsSource (sourceObj)
return sourceBox

###############################

def createTargetBox (targetObj):

targetBox = lConstraintRelation.ConstrainObject (targetObj)
return targetBox

###############################

def connectThem (sourceBox, sourceChannel, targetBox, targetChannel):

OUT = FindAnimationNode (sourceBox.AnimationNodeOutGet(),sourceChannel)
IN = FindAnimationNode (targetBox.AnimationNodeInGet(),targetChannel)
FBConnect (OUT, IN)

###############################

lConstraintRelation = FBConstraintRelation('Test')

myBox = FBModelMarker('My_Box')
myBox.Show = True
myBox.PropertyCreate('Test', FBPropertyType.kFBPT_int, 'Integer', True, True, None)

myBox1 = FBModelMarker('My_Box1')
myBox1.Show = True
myBox1.PropertyCreate('Test', FBPropertyType.kFBPT_int, 'Integer', True, True, None)

x = createSourceBox (myBox)
y = createTargetBox (myBox1)

connectThem (x, 'Rotation', y, 'Rotation')
connectThem (x, 'Translation', y, 'Translation')



but if I change the last two lines to connect the Custom "Test" Property...



connectThem (x, 'Test', y, 'Test')
connectThem (x, 'Translation', y, 'Translation')



I get a crash...

Any help would be much appreciated...

Cheers

Peter
2 REPLIES 2
Message 2 of 3
stevkalinowski
in reply to: Anonymous

The new custom property must be set to Animated in order for the plug to be available to use in a Relation Constraint. This is the equivalent of toggling the "A" button next to the property in the Property Editor.


Modified code:

lConstraintRelation = FBConstraintRelation('Test')

myBox = FBModelMarker('My_Box')
myBox.Show = True
lBoxProp = myBox.PropertyCreate('Test', FBPropertyType.kFBPT_int, 'Integer', True, True, None)
# Set the new property to Animatable
lBoxProp.SetAnimated(True)

myBox1 = FBModelMarker('My_Box1')
myBox1.Show = True
lBoxProp1 = myBox1.PropertyCreate('Test', FBPropertyType.kFBPT_int, 'Integer', True, True, None)
# Set the new property to Animatable
lBoxProp1.SetAnimated(True)

x = createSourceBox (myBox)
y = createTargetBox (myBox1)

connectThem (x, 'Rotation', y, 'Rotation')
connectThem (x, 'Translation', y, 'Translation')

connectThem (x, 'Test', y, 'Test')




Stev
Message 3 of 3
Anonymous
in reply to: Anonymous

Thanks Stev...

I did finally cobble something together from the standard documentation after a long time searching through forums etc. and came up with this:

myBox = FBModelMarker('My_Box')
myBox.Show = True
myBox.PropertyCreate('Test', FBPropertyType.kFBPT_int, 'Integer', True, True, None)

editProperty = myBox.PropertyList.Find('Test')
editProperty.SetAnimated(True)


Which is, I guess pretty much the same - but I think for keeping it tidy I'll be using yours...!!!

Very much appreciated.

Cheers

Peter

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report