{"id":747,"date":"2019-11-21T10:05:02","date_gmt":"2019-11-21T15:05:02","guid":{"rendered":"http:\/\/www.vicdebaie.com\/blog\/?p=747"},"modified":"2019-11-21T10:05:10","modified_gmt":"2019-11-21T15:05:10","slug":"motionbuilder-python-mirror-character-animation-through-story-mode","status":"publish","type":"post","link":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-mirror-character-animation-through-story-mode\/","title":{"rendered":"MotionBuilder Python &#8211; Mirror Character Animation Through Story Mode"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"748\" data-permalink=\"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-mirror-character-animation-through-story-mode\/sponge-head-sb-mirror-cap-spongebob-mirroring\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/Mirror-Cap.jpg?fit=960%2C640\" data-orig-size=\"960,640\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;https:\\\/\\\/www.maxpixel.net\\\/&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;Sponge Head Sb Mirror Cap Spongebob Mirroring&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;Copyright by MaxPixel&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;Sponge Head Sb Mirror Cap Spongebob Mirroring&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/Mirror-Cap.jpg?fit=300%2C200\" data-large-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/Mirror-Cap.jpg?fit=678%2C452\" decoding=\"async\" loading=\"lazy\" width=\"678\" height=\"452\" src=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/Mirror-Cap.jpg?resize=678%2C452\" alt=\"\" class=\"wp-image-748\" srcset=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/Mirror-Cap.jpg?w=960 960w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/Mirror-Cap.jpg?resize=300%2C200 300w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/Mirror-Cap.jpg?resize=768%2C512 768w\" sizes=\"(max-width: 678px) 100vw, 678px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>One of my first posts on this blog showed how to mirror animations via python. The script would set the mirrored option to &#8220;ON&#8221; for the character and then plot the animation to the Skeleton and then back to the Control Rig &#8211; which works. Recently I was asked if there was a way to mirror an animation along a specific axis and there is via Story Mode. In this post I will go over how we can mirror animations via Story Mode using Python scripting in MotionBuilder.<\/p>\n\n\n\n<p>Below you will find the script which uses a currently selected character and copies the data to a new take called &#8220;<em>original_take_name<\/em>-Mirrored&#8221;.  The script will  mirror the character&#8217;s data based on the users desired Plane Option (XY, ZY, XZ) by using FBStoryClipMirrorPlane. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pyfbsdk as fb\n\n##Create A New Take\ndef CreateMirrorTake():\n    takeName = fb.FBSystem().CurrentTake.LongName+\"_Mirrored\"\n    fb.FBSystem().CurrentTake.CopyTake( takeName )\n\n##Plot The Story Clip\ndef PlotCharacterClip( character = object ):\n    lPlotClipOptions = fb.FBPlotOptions()\n    lPlotClipOptions.ConstantKeyReducerKeepOneKey = False\n    lPlotClipOptions.PlotAllTakes = False\n    lPlotClipOptions.PlotOnFrame = True\n    lPlotClipOptions.PlotPeriod = fb.FBTime( 0, 0, 0, 1 )\n    lPlotClipOptions.PlotTranslationOnRootOnly = False\n    lPlotClipOptions.PreciseTimeDiscontinuities = False\n    lPlotClipOptions.RotationFilterToApply = fb.FBRotationFilter.kFBRotationFilterUnroll\n    lPlotClipOptions.UseConstantKeyReducer = False\n    character.PlotAnimation (fb.FBCharacterPlotWhere.kFBCharacterPlotOnSkeleton,lPlotClipOptions )               \n    character.PlotAnimation(fb.FBCharacterPlotWhere.kFBCharacterPlotOnControlRig,lPlotClipOptions ) \n\n##Send Character To A Story Clip And Plot The Data Mirrored\ndef MirrorCharacter( character = object, XY = False, ZY = False, XZ = False ):\n    if XY == ZY == XZ == False: pass\n    \n    else:\n        ##Create A Character Stroy Track And Add Currect Take As A Clip\n        track = fb.FBStoryTrack( fb.FBStoryTrackType.kFBStoryTrackCharacter, fb.FBStory().RootFolder )\n        track.Details.append( character )\n        track.CopyTakeIntoTrack( fb.FBSystem().CurrentTake.LocalTimeSpan, fb.FBSystem().CurrentTake )\n        \n        ##Turn Story Mode \"ON\"\n        orgStoryMute = fb.FBStory().Mute\n        if orgStoryMute == True:\n            fb.FBStory().Mute = False\n    \n        ##Get Mirror Plane Options\n        if XY == True: mirrorplaneOption = fb.FBStoryClipMirrorPlane.kFBStoryClipMirrorPlaneXY\n        if ZY == True: mirrorplaneOption = fb.FBStoryClipMirrorPlane.kFBStoryClipMirrorPlaneZY\n        if XZ == True: mirrorplaneOption = fb.FBStoryClipMirrorPlane.kFBStoryClipMirrorPlaneXZ\n        ##Set All Clips On Provided Track To Be Mirrored\n        for clip in track.Clips:\n            clip.SolvingMode        = fb.FBStoryClipSolveMode.kFBStoryClipRetargetSkeleton  ##Sets The Solving Mode To \"RetargetSkeleton\" Which Seems To Give Mirrored Result\n            clip.MirrorPlane        = mirrorplaneOption                                     ##Set Mirror Plane Options Based Off Of The User's Checked Box \n            clip.MirrorAnimation    = True\n        \n        ##Plot Mirrored Story Data Back To Take\n        PlotCharacterClip( character )\n        \n        ##Delete Stroy Track\n        track.FBDelete()\n        \n        ##Set Story Mute Back To Original Setting\n        fb.FBStory().Mute = orgStoryMute\n        \n\n        CreateMirrorTake()\n\n##Mirror Current Character Along Mirror Plane ZY    \nMirrorCharacter( fb.FBApplication().CurrentCharacter, XY = False, ZY = True, XZ = False  )\n<\/code><\/pre>\n\n\n\n<p>I hope this helps.<\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>A quick script that will mirror animations via Story Mode.<\/p>\n","protected":false},"author":1,"featured_media":748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"MotionBuilder Python - Mirror Character Animation Through Story Mode\n\n#mirroranimation #motionbuilder #python","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[4],"tags":[18,16,5],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/Mirror-Cap.jpg?fit=960%2C640","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8pltq-c3","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":292,"url":"http:\/\/www.vicdebaie.com\/blog\/mirroring-motionbuilder-character-animation-with-python\/","url_meta":{"origin":747,"position":0},"title":"Mirroring MotionBuilder Character Animation with Python","author":"admin","date":"March 13, 2017","format":false,"excerpt":"In a previous post I went over \"Plotting and Plot Options\" as well as \"dir\" where we exposed the \"MirrorMode\" of a Character. Now with all that information exposed I will show you how I created a simple script that will mirror a\u00a0Character's animation, first by setting the \"MirrorMode\" to\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"http:\/\/www.vicdebaie.com\/blog\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/02\/img_4039-1.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":276,"url":"http:\/\/www.vicdebaie.com\/blog\/saving-motionbuilder-character-animation-with-python\/","url_meta":{"origin":747,"position":1},"title":"Saving MotionBuilder Character Animation with Python","author":"admin","date":"April 5, 2017","format":false,"excerpt":"When I get Mocap it's usually in a messy scene. Optics, Markets, strange NameSpace, etc. they all can bog down a scene. One of the first thing I do is save out the Character Animation and load it back into a clean scene. Using Python to save out Character Animation\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"http:\/\/www.vicdebaie.com\/blog\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/03\/img_4059-1.jpg?fit=300%2C200&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":794,"url":"http:\/\/www.vicdebaie.com\/blog\/using-motionbuilder-python-to-offset-all-animations-within-a-scene\/","url_meta":{"origin":747,"position":2},"title":"Using MotionBuilder Python To Offset All Animations Within A Scene","author":"admin","date":"January 7, 2021","format":false,"excerpt":"Here is a quick script that will allow you to shift\/offset all animation keys within a scene. Previously I would do this via story mode or use another technique that would skip over props and\/or constraints. This script should shift everything within the scene that is animated. The script is\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"http:\/\/www.vicdebaie.com\/blog\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/01\/OffSet-1.jpg?fit=960%2C540&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/01\/OffSet-1.jpg?fit=960%2C540&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/01\/OffSet-1.jpg?fit=960%2C540&resize=700%2C400 2x"},"classes":[]},{"id":81,"url":"http:\/\/www.vicdebaie.com\/blog\/plotting-character-animation-with-a-motionbuilder-python-script\/","url_meta":{"origin":747,"position":3},"title":"Plotting Character Animation With A MotionBuilder Python Script .\u00a0","author":"admin","date":"February 9, 2017","format":false,"excerpt":"Let's go over how to use Python to plot animation onto a character's Control Rig. The interesting part of this is\u00a0the \"plot options\" and how we call back on them when we plot. \u00a0 These are the settings I use when I am processing large motion capture data down to\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"http:\/\/www.vicdebaie.com\/blog\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":83,"url":"http:\/\/www.vicdebaie.com\/blog\/using-python-to-create-a-layer-on-the-current-selected-take-in-motionbuilder\/","url_meta":{"origin":747,"position":4},"title":"Using Python to Create a layer on the Current Selected Take in MotionBuilder.\u00a0","author":"admin","date":"February 9, 2017","format":false,"excerpt":"In MotionBuilder using animation layers are great for edits, blending, additives and in general adding quality passes to your animations. So below I'm going to demo how I learned to add layers\u00a0using Python. To create an Animation Layer on the Current Take script: Now let's setup a Python Script to\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"http:\/\/www.vicdebaie.com\/blog\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":274,"url":"http:\/\/www.vicdebaie.com\/blog\/using-python-to-import-motionbuilder-characters-into-story\/","url_meta":{"origin":747,"position":5},"title":"Using Python to import MotionBuilder Characters into story.\u00a0","author":"admin","date":"April 6, 2017","format":false,"excerpt":"\u00a0 MotionBuilder comes with a great script that will place your selected character into a Character Track within the Story, I wanted to write one that would put all of the scene's Characters into the story. Once again I will use the \"Mia_Rigged.fbx\" file to test my script. I created\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"http:\/\/www.vicdebaie.com\/blog\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/MobuPython_StoryScript.jpg?fit=1011%2C224&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/MobuPython_StoryScript.jpg?fit=1011%2C224&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/MobuPython_StoryScript.jpg?fit=1011%2C224&resize=700%2C400 2x"},"classes":[]}],"_links":{"self":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/747"}],"collection":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/comments?post=747"}],"version-history":[{"count":1,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/747\/revisions"}],"predecessor-version":[{"id":749,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/747\/revisions\/749"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media\/748"}],"wp:attachment":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media?parent=747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/categories?post=747"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/tags?post=747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}