|
|
|
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®
|
|
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
|
|
|
|
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
|
|
|
|
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(pObject, pName):
for each in pObject.PropertyList:
if each.GetName()==pName:
return each
cnsmng = FBConstraintManager() x = 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() F = an.FCurve
actref = PropFind(cns, "Active Parent Index") an2 = actref.GetAnimationNode() F2 = an2.FCurve
for each in F.Keys:
F2.KeyAdd(each.Time, each.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
|
|
|
|
|
|