<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Quick way of spitting out Ik blend values for each frame Python. in MotionBuilder Forum</title>
    <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10204152#M764</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to find the most efficient way of spitting out the IK blend values for a selected object (auxilliary effector).&lt;BR /&gt;I can get it to spit out the values but it takes an age.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;from pyfbsdk import *

lSystem=FBSystem()
lScene = lSystem.Scene
playaCtrl = FBPlayerControl()

#Start and end frames
StartFrame = FBSystem().CurrentTake.LocalTimeSpan.GetStart()
EndFrame = FBSystem().CurrentTake.LocalTimeSpan.GetStop()

#Start and end frames
start = StartFrame.GetFrame() 
end = EndFrame.GetFrame() 

#Number of character records
numOfFrames = int(end) - int(start)


selectedModelList = FBModelList()

FBGetSelectedModels( selectedModelList )
 
for selectedModel in selectedModelList:
    print numOfFrames
    print selectedModel.LongName
    node = selectedModel.Translation.GetAnimationNode()
    fcurve = node.Nodes[0].FCurve
    
    for i in range(0, len(fcurve.Keys)): 
            
        theFrame = FBTime( 0, 0, 0, i )
        playaCtrl.Goto (theFrame)
        
        key = fcurve.Keys[i]
        Frame = key.Time.GetFrame()

        #Find the ik reach properties and set the blend value
        propsName = ['IK Reach Translation']
        
        for propName in propsName:
            
            prop = selectedModel.PropertyList.Find(propName)
            print (str(Frame) +"-"+ str(prop))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; Is there a much quicker way?&lt;BR /&gt;&lt;BR /&gt;Thank You.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Apr 2021 09:20:20 GMT</pubDate>
    <dc:creator>petecmartin</dc:creator>
    <dc:date>2021-04-01T09:20:20Z</dc:date>
    <item>
      <title>Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10204152#M764</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to find the most efficient way of spitting out the IK blend values for a selected object (auxilliary effector).&lt;BR /&gt;I can get it to spit out the values but it takes an age.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;from pyfbsdk import *

lSystem=FBSystem()
lScene = lSystem.Scene
playaCtrl = FBPlayerControl()

#Start and end frames
StartFrame = FBSystem().CurrentTake.LocalTimeSpan.GetStart()
EndFrame = FBSystem().CurrentTake.LocalTimeSpan.GetStop()

#Start and end frames
start = StartFrame.GetFrame() 
end = EndFrame.GetFrame() 

#Number of character records
numOfFrames = int(end) - int(start)


selectedModelList = FBModelList()

FBGetSelectedModels( selectedModelList )
 
for selectedModel in selectedModelList:
    print numOfFrames
    print selectedModel.LongName
    node = selectedModel.Translation.GetAnimationNode()
    fcurve = node.Nodes[0].FCurve
    
    for i in range(0, len(fcurve.Keys)): 
            
        theFrame = FBTime( 0, 0, 0, i )
        playaCtrl.Goto (theFrame)
        
        key = fcurve.Keys[i]
        Frame = key.Time.GetFrame()

        #Find the ik reach properties and set the blend value
        propsName = ['IK Reach Translation']
        
        for propName in propsName:
            
            prop = selectedModel.PropertyList.Find(propName)
            print (str(Frame) +"-"+ str(prop))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; Is there a much quicker way?&lt;BR /&gt;&lt;BR /&gt;Thank You.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 09:20:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10204152#M764</guid>
      <dc:creator>petecmartin</dc:creator>
      <dc:date>2021-04-01T09:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10205040#M765</link>
      <description>&lt;P&gt;You could try something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyfbsdk import *

def GetSelModelIKValues():
    myIKProperties = ['IK Reach Translation', 'IK Reach Rotation', 'IK Pull']
    ##Get A List Of Selected Models
    modelList = FBModelList()
    FBGetSelectedModels (modelList)
    ##Create A List
    ikInfo = [] 
    for model in modelList:
        modelData={"Model": model}
        for IKProperty in myIKProperties:
            modelData[IKProperty] = model.PropertyList.Find(IKProperty).GetAnimationNode()
        ikInfo.extend([modelData])
        
    ##Print Out Information    
    for dict in mytest:
        print '--------------------------------'
        print dict['Model'].LongName
        for IKProperty in myIKProperties:
            print '\r', IKProperty + 'Key Info:'
            for k in dict[IKProperty].FCurve.Keys:
                print 'Key at time %s = %.3f' % (k.Time.GetTimeString(), k.Value)
    
    ##Return List Of Dictionary
    return ikInfo
            
myIK = GetSelModelIKValues()
    
    
    &lt;/LI-CODE&gt;&lt;P&gt;This will print our the values as well as return a list of dictionaries that containt he IK Animation Nodes - from there you could reference them again to edit or remove the key times and values (as well as the tangents for each key).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 14:51:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10205040#M765</guid>
      <dc:creator>vdebaie</dc:creator>
      <dc:date>2021-04-01T14:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10205464#M766</link>
      <description>&lt;P&gt;also, if you wanted to print what the ik values are on EVERY frame (which will take a long time based on the number of selected models and the number of frames within the take), you could do this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyfbsdk import *

def printIKValues():
    ##Get A List Of Selected Models
    modelList = FBModelList()
    FBGetSelectedModels (modelList)
    ##For Each Model Print Out The IK Values For Each Frame
    for model in modelList:
        #Added '1 +' to the range to get the entire time line range       
        for frame in range(1 + FBSystem().CurrentTake.LocalTimeSpan.GetDuration().GetFrame()):
            t = fb.FBTime(0, 0, 0, frame, 0)
            FBPlayerControl().Goto(t)
            print 'Model Name:', model.LongName
            print "Frame #", frame
            print 'IK Reach Translation =', model.PropertyList.Find('IK Reach Translation').Data
            print 'IK Reach Rotation =', model.PropertyList.Find('IK Reach Rotation').Data
            print 'IK Pull =', model.PropertyList.Find('IK Pull').Data&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 01 Apr 2021 17:25:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10205464#M766</guid>
      <dc:creator>vdebaie</dc:creator>
      <dc:date>2021-04-01T17:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10205501#M767</link>
      <description>&lt;P&gt;Awesome, thank you &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4400628"&gt;@vdebaie&lt;/a&gt;!&amp;nbsp; I'll do a bit of tinkering and see which is the most efficient &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 17:42:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10205501#M767</guid>
      <dc:creator>petecmartin</dc:creator>
      <dc:date>2021-04-01T17:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10209431#M768</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4400628"&gt;@vdebaie&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I couldn't get the first example to work? It said that 'mytest' was undefined?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Apr 2021 14:31:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10209431#M768</guid>
      <dc:creator>petecmartin</dc:creator>
      <dc:date>2021-04-03T14:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10212345#M769</link>
      <description>&lt;P&gt;Sorry, I replied earlier on my phone but the post did not go through.&lt;BR /&gt;&lt;BR /&gt;I made a typo in my first example this should fix it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyfbsdk import *

def GetSelModelIKValues():
    myIKProperties = ['IK Reach Translation', 'IK Reach Rotation', 'IK Pull']
    ##Get A List Of Selected Models
    modelList = FBModelList()
    FBGetSelectedModels (modelList)
    ##Create A List
    ikInfo = [] 
    for model in modelList:
        modelData={"Model": model}
        for IKProperty in myIKProperties:
            modelData[IKProperty] = model.PropertyList.Find(IKProperty).GetAnimationNode()
        ikInfo.extend([modelData])
        
    ##Print Out Information    
    for dict in ikInfo:
        print '--------------------------------'
        print dict['Model'].LongName
        for IKProperty in myIKProperties:
            print '\r', IKProperty + 'Key Info:'
            for k in dict[IKProperty].FCurve.Keys:
                print 'Key at time %s = %.3f' % (k.Time.GetTimeString(), k.Value)
    
    ##Return List Of Dictionary
    return ikInfo
            
myIK = GetSelModelIKValues()&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 05 Apr 2021 13:03:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10212345#M769</guid>
      <dc:creator>vdebaie</dc:creator>
      <dc:date>2021-04-05T13:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10212688#M770</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4400628"&gt;@vdebaie&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I'll give it a test later matey.&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the looks of things you have to do the whole 'GotoFrame' thing which is what takes the time.&lt;/P&gt;&lt;P&gt;I'm sure I've done something similar before but for translation and rotation data and it was a lot quicker u.&amp;nbsp; I think that returned all the fcurve key values.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 15:20:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10212688#M770</guid>
      <dc:creator>petecmartin</dc:creator>
      <dc:date>2021-04-05T15:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10213849#M771</link>
      <description>&lt;P&gt;yes. going frame by frame takes alot of time.&lt;BR /&gt;&lt;BR /&gt;the second version quickly brings back all the key info (frames and values) for each of the IK curves.&lt;BR /&gt;&lt;BR /&gt;you could try applying a resample filter on the ik curves and then getting the values for every key (there would be as many keys as frames if you reasmple to meet the time line) - no idea if that would be fast (it is when you do it manually).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR&lt;BR /&gt;&lt;BR /&gt;if you know the key values and key times along with the total frames on the time line that your could set the curves to be linear and then using math you would know the values of each frame between the keys.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 00:57:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10213849#M771</guid>
      <dc:creator>vdebaie</dc:creator>
      <dc:date>2021-04-06T00:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10214237#M772</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4400628"&gt;@vdebaie&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;Thank you, the revised version worked brilliantly!&amp;nbsp; Super quick.&amp;nbsp; Thanks for all your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 05:31:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10214237#M772</guid>
      <dc:creator>petecmartin</dc:creator>
      <dc:date>2021-04-06T05:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10218425#M773</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4400628"&gt;@vdebaie&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;A quick question. If I've set a key on a frame for the reaches, how do I then set the interpolation/ tangent of that key?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 12:24:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10218425#M773</guid>
      <dc:creator>petecmartin</dc:creator>
      <dc:date>2021-04-07T12:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10218987#M774</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4400628"&gt;@vdebaie&lt;/a&gt;&amp;nbsp;, Meant to ask a different question!&lt;BR /&gt;&lt;BR /&gt;I'm stuck as to how to set keys on the&amp;nbsp;&lt;SPAN&gt;'IK Reach Translation' and '&lt;/SPAN&gt;&lt;SPAN&gt;'IK Reach Rotation'.&lt;BR /&gt;I've managed to export the original values out to a text file, I then want to read them in and apply them to auxiliary effector again.&amp;nbsp; The trouble i'm having is that I managed to remove all the Reach keys from the effector, I just can't seem to add keys to the reaches at the correct times and tangent/interpolation.&amp;nbsp;&lt;BR /&gt;Do you know of any ways to set keys on the reach values?&lt;BR /&gt;Cheers,&amp;nbsp;&lt;BR /&gt;Pete&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 14:53:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10218987#M774</guid>
      <dc:creator>petecmartin</dc:creator>
      <dc:date>2021-04-07T14:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10222006#M775</link>
      <description>&lt;P&gt;This should get you started.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;from pyfbsdk import *

'''
Here is a rough funciton that will help you achieve your goal. When calling the function you can set the
frame and ik value as well as set the tanget mode - but that is really it.

To find out more on setting tangent modes, interpolations and tangent weights
Alex Forsythe has a great write up @ http://awforsythe.com/tutorials/pyfbsdk-7
'''

##pFrame is the frame you want your key set on
##pIKVal is the value you want the ik to be
##pInterpolation is set to linear by default in then funciton but it can be change when calling the function

def SetIKKeysOnSelected(pFrame=int, pIKVal=int, pInterpolation=FBInterpolation.kFBInterpolationLinear):
    myIKProperties = ['IK Reach Translation', 'IK Reach Rotation', 'IK Pull']
    ##Get A List Of Selected Models
    modelList = FBModelList()
    FBGetSelectedModels (modelList)

    for model in modelList:
        for IKProperty in myIKProperties:
            ikFCurve = model.PropertyList.Find(IKProperty).GetAnimationNode().FCurve
            keyIndex = ikFCurve.KeyAdd(FBTime(0, 0, 0, pFrame, 0), pIKVal)
            ikFCurve.Keys[keyIndex].Interpolation = pInterpolation
            
##Setting 3 key with linear interpolation
SetIKKeysOnSelected(0, 0) ##at frame 0 set the ik vaules to be 0           
SetIKKeysOnSelected(45, 10)##at frame 45 set the ik values to be 10
SetIKKeysOnSelected(90, 100)##at frame 90 set the ik values to be 100

##Setting 3 keys with Cubic interpolation
SetIKKeysOnSelected(110, 0, FBInterpolation.kFBInterpolationCubic)           
SetIKKeysOnSelected(125, 50, FBInterpolation.kFBInterpolationCubic)
SetIKKeysOnSelected(150, 100, FBInterpolation.kFBInterpolationCubic)
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Apr 2021 14:05:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10222006#M775</guid>
      <dc:creator>vdebaie</dc:creator>
      <dc:date>2021-04-08T14:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Quick way of spitting out Ik blend values for each frame Python.</title>
      <link>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10222214#M776</link>
      <description>&lt;P&gt;Fantastic! Thank you &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4400628"&gt;@vdebaie&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 15:01:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/motionbuilder-forum/quick-way-of-spitting-out-ik-blend-values-for-each-frame-python/m-p/10222214#M776</guid>
      <dc:creator>petecmartin</dc:creator>
      <dc:date>2021-04-08T15:01:51Z</dc:date>
    </item>
  </channel>
</rss>

