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 / duplicate hierarchy and relationconstraint them
  RSS 2.0 ATOM  

duplicate hierarchy and relationconstraint them
Rate this thread
 
46481
 
Permlink of this thread   Subscribe to this thread
avatar
  • Seb123
  • Posted: 23 August 2010 01:33 AM
  • Total Posts: 92
  • Joined: 05 November 2009 10:41 AM

sooo.... a whole bunch of questions. Some of them probably easy for you guys ;-)

I have a skeleton, and need to have it drive an “Export” skeleton. I could probably make it work with what I have, but it would be a novel of a script ;-)

What I basically need is a way of copying a bone hierarchy, and add a namespace to the new one.
I can copy all the bones, but they don’t stay in a hierarchy.
It also renames the bones, even when a namespace is added.
Normally when I do that manually it adds a “1” in the namespace and not the bone. Why is it not working the same way when scripted?

After that is done, I need to have the original bones to drive the “Export” skeleton.
I have created the relation-constraint and managed to connect two boxes, but I need a way to have it do that for all the bones in the hierarchy.

I’m still quite new at all this, so any help is appreciated.

Thanks



Replies: 0
avatar
  • Seb123
  • Posted: 25 August 2010 04:16 AM

Sooo.... I got the duplicate working. Here it is if anyone has the same problem. I anyone has an easier way I would love to see it.

from pyfbsdk import *

def Clone (lModel):    
    
lClone FBModelSkeleton ("Temp")   ### creates model
    
lClone.Show True
    lClone
.Color FBColor (1,0,0)
    
lClone.ProcessObjectNamespace(FBNamespaceAction.kFBConcatNamespace"namespace"""False)        ### gives model a namespace and gets org name
    
lClone.Name lModel.Name
            
    lParent 
lModel.Parent
    
if lParent == None:         ###Checks for parents
        
None    
    
else:
        
lParentName lParent.Name      ### Finds "namespace" parent from the org skeleton
        
cl FBComponentList() 
        
lObj FBFindObjectsByNamespace"namespace"cl )     ### Looks for all "namespace" objects
        
for lObj in cl:                            
            if 
lObj.Name == lParentName:                ### If "namespace"name matches org parent name then find same clones objects and parent 
                
foundlObj FBFindModelByName (lObj.LongName)
                
lClone.Parent foundlObj
        
    lVector 
FBVector3d ()         ### copies the pos and rot
    
lModel.GetVector lVector,  FBModelTransformationMatrix.kModelTranslationFalseNone)
    
lClone.SetVector lVector,  FBModelTransformationMatrix.kModelTranslationFalseNone)
    
lModel.GetVector lVector,  FBModelTransformationMatrix.kModelRotationFalseNone)
    
lClone.SetVector lVector,  FBModelTransformationMatrix.kModelRotationFalseNone)    

    
lchild lModel.Children
    
for child in lchild:
        Clone (
child)

Clone (
FBFindModelByName ("Root"))

What i need now is to find a way to connect the translation and rotation of the two skeletons in a Relations constraint. I’ll post if I find a way.



Replies: 0
avatar
  • Seb123
  • Posted: 02 September 2010 02:48 AM

Sooo, I’ve figured out everything except connecting the boxes in the relation constraint.

I have a bunch of boxes with a name, and the same ones with a namespace. And I need to connect the translation and rotation.
so, sender “spine” sends translation and rotation to receiver “Namespace:spine”

Any way of getting that working???

Thanks in advance



Replies: 0




   
  Settings Choose Theme color: