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 / Key Property
  RSS 2.0 ATOM  

Key Property
Rate this thread
 
22887
 
Permlink of this thread  
avatar
  • mondog
  • Posted: 17 February 2009 08:55 AM
  • Total Posts: 27
  • Joined: 24 May 2007 12:39 PM

Hi,

I’m trying to get a Multi Ref constraint to switch active references based on the camera swticher.

The quickest and easiest way to achieve this via the gui, is to copy the index curve from the switcher to the Active Reference index channel.

Assuming i have to iterate through the curve to get a list of keys and times from the source curve and write this to the target via Python:

I’ve hit a bit of a wall, Constraints as don’t have FBAnimationNode attributes.I’ve re-read Jason’s animation section from the Python Masterclass and scoured the web for an example of a non-FBModel property getting keyed and i’ve come up empty. Everything i’ve tried seems to reference FBAnimationNode.  I can set all of the states for the Multi-Ref offset properties (whether they are animated or not and their values etc.), but i’m unable unable to set a key for them.

Can someone point me in the write direction?

Thanks
mondo



Replies: 0
avatar
  • mondog
  • Posted: 19 February 2009 08:07 AM

No replies :(

i’ll keep chipping away, but in the meantime i found a workaround to anyone who’s interested.

i didn’t realise that it’s possible to add constraints into the relation too (i know) but, it seems i can simply add the switcher and the multiref to this constraint and connect the index.

It doesn’t seem to work until I plot the Active reference curve, thereafter it works as expected.

I’d still love to know if/how to key a property directly as it would be a bit cleaner than this approach.

Thanks
Mondo



Replies: 0
avatar
  • CPaulin
  • Posted: 04 March 2009 04:21 PM

Hi, Here is the code to do what you want…

from pyfbsdk import *

def GetConstraintIndex(pName):
    
cnsm FBConstraintManager()
    for 
x in range(cnsm.TypeGetCount()):
        if 
cnsm.TypeGetName(x)==pName:
            return 
x
    
return -1

def PropFind
(pObjectpName):
    for 
each in pObject.PropertyList:
        if 
each.GetName()==pName:
            return 
each
             
cnsmng 
FBConstraintManager()
GetConstraintIndex("Multi Referential")
cns cnsmng.TypeCreateConstraint(x)
rigids PropFind(cns,"RigidObjects")

rigids.append(FBModelCube("CubeRigid1"))
rigids.append(FBModelCube("CubeRigid2"))
rigids.append(FBModelCube("CubeRigid3"))
rigids.append(FBModelCube("CubeRigid4"))

cs FBFindModelByName("Camera Switcher")
camidx PropFind(cs"Camera Index")
an camidx.GetAnimationNode()
an.FCurve

actref 
PropFind(cns"Active Parent Index")
an2 actref.GetAnimationNode()
F2 an2.FCurve

for each in F.Keys:
    
F2.KeyAdd(each.Timeeach.Value)

It may need more adjustment to exactly do what you want but should give you the big picture…



CHARLES PAULIN | SQA AUTOMATION ANALYST
AUTODESK Media & Entertainment

Replies: 0