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 / [Solved] get all Fcurves in scene
  RSS 2.0 ATOM  

[Solved] get all Fcurves in scene
Rate this thread
 
48505
 
Permlink of this thread  
avatar
  • Seb123
  • Posted: 18 October 2010 09:46 PM
  • Total Posts: 92
  • Joined: 05 November 2009 10:41 AM

Hi,

I’m trying to apply a scale filter onto all curves in my scene. I got it working by applying the filter on nodes, but then it doesn’t make any change to the Ik effectors reach.
So what I’m thinking is too apply the filter on all FCurves, but I cant seem to find a way to get to all of them.

Any help?



Replies: 0
avatar
  • KxL
  • Posted: 30 October 2010 07:39 AM

Fastest way is to apply your filter on Model.AnimationNodes. Run this script while having selected IK with animatable Reach property and see results

from pyfbsdk import *

lModels FBModelList()
FBGetSelectedModels(lModels)

def PrintNodes(pRootNode):
    print 
pRootNode.Name
    
if len(pRootNode.Nodes) == 0:
        
# here we have fcurve
        
print pRootNode.FCurve
    
for lNode in pRootNode.Nodes:
        
PrintNodes(lNode)

for 
lModel in lModels:
    print 
lModel.Name
    PrintNodes
(lModel.AnimationNode)

Other way is to find property and get animation node from it and then FCurve.

Cheers!



Replies: 0
avatar
  • Seb123
  • Posted: 01 November 2010 03:05 AM

cool, thanks for the reply, I see what it does, but then I cant get the filter to work. No matter what I try. Either it gives me an error or simply does nothing.
I tried running the filter on both nodes and curves with no luck.



Replies: 0
avatar
  • KxL
  • Posted: 07 November 2010 04:10 AM

Oh, you mean, MB filter? Because as far as I remember, it require keys to be selected ? I think there were already a post about that...let me know.



Replies: 0
avatar
  • Seb123
  • Posted: 10 November 2010 10:31 PM

I want it to apply a filter to all fcurves or animation nodes in the entire scene. skeleton, rig, constraints, etc.

I tried using these:

lFilter.Apply(FBFCurve pCurve)
Does not work. either gives error or does nothing.

lFilter.Apply( lModel.Translation.GetAnimationNode(), True )
This one I got working, but then I don’t get nodes that are other than translation, rotation and Scale. No reach T and R, constraints etc.

here is what I got so far. its loading for some time, no errors, but I cant see any change

lFilterManager FBFilterManager()

def PrintNodes(pRootNode): 
    for 
lNode in pRootNode.Nodes:  
          
        if 
len(pRootNode.Nodes) == 0:
            
# here we have fcurve
            
print pRootNode.FCurve
            lFilter 
lFilterManager.CreateFilter"Time Shift And Scale" )
            
lFilter.PropertyList.Find("Scale").Data scaleFactor
            lFilter
.Apply (pRootNode.FCurveTrue)  
                 
        for 
lNode in pRootNode.Nodes:
            
PrintNodes(lNode)

for 
lModel in FBSystem().Scene.Components:
    if 
"AnimationNode" in dir(lModel):
        print 
""
        
print lModel.Name
        PrintNodes
(lModel.AnimationNode)


Replies: 1
/img/forum/dark/default_avatar.png

I am not very sure why you can’t use AnimationNode that I showed...so lets do it differently :)

from pyfbsdk import *

gFilterManager FBFilterManager()
gFilter gFilterManager.CreateFilter"Time Shift And Scale" )
gFilter.PropertyList.Find("Scale").Data 20
         
for lComponent in FBSystem().Scene.Components:
    if 
lComponent and lComponent.Is(FBModel_TypeInfo()):
        for 
lProp in lComponent.PropertyList:
            if 
lProp and lProp.IsAnimatable() and lProp.IsAnimated():
                
gFilter.Apply (lProp.GetAnimationNode(), True)
Author: KxL

Replied: 20 November 2010 08:46 AM  
avatar
  • Seb123
  • Posted: 22 November 2010 07:48 PM

Thanks KxL, it works. i just had to remove this one line.
if lComponent and lComponent.Is(FBModel_TypeInfo()):



Replies: 0