|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| python help producing function box on Relational Constraint
|
|
|
hi all,
I am trying to create an Add function box inside a relational constraint.
I have managed to create the relational constraint on the selected object and created other sender boxes/FunctionBoxes (number to vector, etc) inside of the constraint and connected them succesfully.
But on creating the Add Function box it crashes motionbuilder. I have even rewritten it three times in a seperate script and it still crashes Motionbuilder Can anyone see what I am doing wrong?
The code:
selectedModels = FBModelList()
FBGetSelectedModels (selectedModels, None, True)
lConstraintRelation = FBConstraintRelation( ‘Sue_ZNull_constraint’ )
lAddBox = lConstraintRelation.CreateFunctionBox(’Number’, ‘Add’)
lConstraintRelation.SetBoxPosition(lAddBox, 10, 50)
The line:
lAddBox = lConstraintRelation.CreateFunctionbox(’Number’, ‘Add’)
is the same code used to create a successful ‘If cond a and b’ functionbox. The only thing changed is the name of the function ‘Add’
help! a confused Sue.
I am using Motionbuilder 2009
many thanks in advance.
Sue.
|
|
|
|
Hi Sue,
MB usually crashes when you add a none existing box into a relation constriant. So the in your sample above should be:
lAddBox = lConstraintRelation.CreateFunctionBox(’Number’, ‘Add (a + b)’)
Just as an example as it can be tricky to se i’ve clearified the spaces with an underscore “Add_(a_+_b)”
Hope it helped!
Cheers,
AV
Choose a job you love, and you will never have to work a day in your life.
|
|
|
|
hi AV,
Many thanks for your response. It worked.
I did try a few different variations with different spaces with and without the a and b. But obviously not that combination, doh!
Thanks again.
Sue
|
|
|
|
hi AV and other MB TD’s,
Just a couple of quick questions. I have almost finished my script but I need to change the sender and reciever boxes to local transformations. The only relevant class I have found are to do with the matrix. Is there any other route to do this?
The other thing is changing a specific value so again in my add box I need to change the value of ‘a’ to an integer of -131 (same as right clicking and Set Value). So far the closest I have found is the WriteData (although I am not entirely clear how this works and what it does) and the SetCandidate. Also is it actually possible to do this in Python?
As you can probably tell I am new to motionbuilder and Python (VB and XSI Person) so would appreciate any help.
many thanks again,
Sue.
|
|
|
|
Hi Sue!
To set the senders and receivers to local do the following:
tmpBox = tmpRelation.ConstrainObject( tmpObj ) tmpBox.UseGlobalTransforms = (False) tmpRelation.SetBoxPosition( tmpBox, 0, 50 )
For setting a value in one of the nodes:
# Find Animation Node in relation constraint
def FindAnimationNode( pParent, pName ):
lResult = None
for lNode in pParent.Nodes:
if lNode.Name == pName:
lResult = lNode
break
return lResult #------------------------------------------------------------- inPlugs = FindAnimationNode(tmpBox .AnimationNodeInGet(), 'a') inPlugs.WriteData ([0])
Hope it helped!
Cheers,
Avalon
Choose a job you love, and you will never have to work a day in your life.
|
|
|
|
hi Avalon,
Thank you so much. I did just manage to find the global transforms in the end but it took me ages to find it in the documentation.
However the changing of the set value I had not been able to do all day and it is getting close to home time which is a great help to me.
By the way I was chatting to my Supervisor Daven and he seems to think you guys might know each other. He worked at Northern lights(I think?) and the other Mocap company in Uppsala. Do you know him? He is a Canadian guy. Anyway he seems to think he may know some of your colleagues at the very least.
I work at Digi guys in Ealing Studios with him.
Thanks again, it is quite stressful learning both Motionbuilder constraints and Python.
Sue.
|
|
|
|
Hi Sue!
Hehe! Of course I know Daven! We worked together for a while a few years back!! I now work, as you mentioned at Northern Light Studios in Uppsala!
Say hi to him from me!
Drop me a mail if you need any more help!
All the best,
Avalon
Choose a job you love, and you will never have to work a day in your life.
|
|
|
|
hi avalon,
I was going to send you a mail but I could not attach an image which I need to do…
Many thanks for all your help with my past problems with python scripting I would not have done it in the time I did without you.
The relation constraint script was completed but there are a few issues with it. For example we wanted to tie the translation of an object to the z translation of another object and the x and Y would be animatable (translated by the animator ) but this is not the case in motionbuilder 2009 . the x and y is fixed so it cannot be moved. We are trying to find a solution for this we have tried expression constraints but that did not work either, still locked. Obviously I do not expect you to do the job for me but it would be of great help if you had any ideas or had a similiar issue. I am new to motionbuilder constraints as well as the sdk and the python so my brain is feeling a little overloaded right now and don’t quite know where to look to solve this one.
cheers Av,
Sue.
| Attachment
|
|
|
|
|
|
Hi Sue!
No problem, glad I could help!
I think I can understand what your trying to do.
Problem here is that you lock the X and Y with your coditions in one way but doesnt allow it to transfere anything else.
You’d need to pipe the values from your Z_Null.Translation --> IF Cond b number I’d imagine. Also, if you’d add animation ontop of the already existing animation from the “Hips” node you could easily add the Translation from your Hips node to your Z_NULL at the beginning or end in the chain. This will allow you to move the Z_Null but till recive it from the Hips…
I hope this made sense..?!?!
If you’d like me to take a closer look you could email me the relation constraint and the Z_Null object and I can take a closer look! I can send you a PM with my mail address.
Cheers,
AV
Choose a job you love, and you will never have to work a day in your life.
|
|
|
|
Hi all,
Thanks for this interesting post. I still have some question :
# Find Animation Node in relation constraint
def FindAnimationNode( pParent, pName ):
lResult = None
for lNode in pParent.Nodes:
if lNode.Name == pName:
lResult = lNode
break
return lResult
#-------------------------------------------------------------
inPlugs = FindAnimationNode(tmpBox .AnimationNodeInGet(), ‘a’)
inPlugs.WriteData ([0])
Is there a way to perform a “ReadData”? I searched for a while and did not find anything…
Do you have an idea ?
Thanks,
L.
|
|
|
|
|
|