{"id":345,"date":"2017-04-25T10:34:15","date_gmt":"2017-04-25T14:34:15","guid":{"rendered":"http:\/\/www.vicdebaie.com\/blog\/?p=345"},"modified":"2018-02-28T11:04:20","modified_gmt":"2018-02-28T16:04:20","slug":"finding-a-characters-namespace-with-motionbuilder-python","status":"publish","type":"post","link":"http:\/\/www.vicdebaie.com\/blog\/finding-a-characters-namespace-with-motionbuilder-python\/","title":{"rendered":"Finding a Character&#8217;s NameSpace with MotionBuilder Python"},"content":{"rendered":"<p><img data-attachment-id=\"346\" data-permalink=\"http:\/\/www.vicdebaie.com\/blog\/finding-a-characters-namespace-with-motionbuilder-python\/12463-nametag600\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?fit=950%2C534\" data-orig-size=\"950,534\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&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;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?fit=300%2C169\" data-large-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?fit=678%2C381\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?resize=300%2C169\" alt=\"\" width=\"300\" height=\"169\" class=\"aligncenter size-medium wp-image-346\" srcset=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?resize=300%2C169 300w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?resize=768%2C432 768w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?resize=712%2C400 712w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?w=950 950w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/p>\n<p>Here is a snippet of script that I use a lot when dealing with Character&#8217;s Name Spaces within MotionBuilder.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n##Setup variables to get all characters within the scene\r\nlAllChars = FBSystem().Scene.Characters\r\n##Setup a variable to get the length of lAllChars - this will be used to creat a loop\r\nlNumberofChars = len(lAllChars)\r\n\r\n##Set up the CharacterInfo Function\r\ndef CharacterInfo(i):\r\n    ##Setup variables Current Character\r\n    lCurrentCharacter = FBSystem().Scene.Characters&#x5B;i]\r\n    ##Select our Current Character\r\n    lCurrentCharacter.Selected = True\r\n    ##Setup variables for our Character's Names - we are going to split the vale at the &quot;:&quot; leaving us with jsut the NameSpace\r\n    lCurrentCharName = lCurrentCharacter.LongName.rsplit(':', 2)&#x5B;0]\r\n    ##print NameSpace\r\n    print lCurrentCharName\r\n\r\n##Run a loop for the the number we created in the variable &quot;lNumberofChars&quot;\r\nfor i in range (lNumberofChars):\r\n    ##Run our function\r\n    CharacterInfo(i)\r\n<\/pre>\n<p>I often split the LongName to provide me with the NameSpace, I find it cleaner to read when I print it out &#8211; which I do often to ensure my scripts are being run on the correct characters at the correct time.<\/p>\n<p>I hope this helps.<\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Here is a snippet of script that I use a lot when dealing with Character&#8217;s Name Spaces within MotionBuilder. ##Setup variables to get all characters within the scene lAllChars = FBSystem().Scene.Characters ##Setup a variable to get the length of lAllChars &#8211; this will be used to creat a loop lNumberofChars = len(lAllChars) ##Set up the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":346,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[4],"tags":[5,7],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/04\/12463-nametag600.jpg?fit=950%2C534","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8pltq-5z","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":274,"url":"http:\/\/www.vicdebaie.com\/blog\/using-python-to-import-motionbuilder-characters-into-story\/","url_meta":{"origin":345,"position":0},"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":[]},{"id":276,"url":"http:\/\/www.vicdebaie.com\/blog\/saving-motionbuilder-character-animation-with-python\/","url_meta":{"origin":345,"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":253,"url":"http:\/\/www.vicdebaie.com\/blog\/move-a-character-in-motionbuilder-to-the-worlds-center-with-python\/","url_meta":{"origin":345,"position":2},"title":"Move a Character in MotionBuilder to the World&#8217;s Center with Python","author":"admin","date":"March 7, 2018","format":false,"excerpt":"\u200eWith a dozen takes in my Motionbuilder scene and my Character placed at different locations on each take, I decided Python would help me move my Character to the World's Center. With raw Mocap data your Character's Wold Position is all based on the Actors position within the volume during\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_4056.jpg?fit=800%2C600&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/02\/IMG_4056.jpg?fit=800%2C600&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/02\/IMG_4056.jpg?fit=800%2C600&resize=700%2C400 2x"},"classes":[]},{"id":336,"url":"http:\/\/www.vicdebaie.com\/blog\/how-to-use-functions-with-motionbuilder-python\/","url_meta":{"origin":345,"position":3},"title":"How to use functions with MotionBuilder Python","author":"admin","date":"April 25, 2017","format":false,"excerpt":"Using functions will save you from re-writing and maintaining many of the same lines of code over and over. What is a Python Function? \"A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and\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\/c2c827b3a6ea16d024b6875b5610651c-e1493127532666.gif?fit=251%2C300&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":528,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-clean-character-from-scene-with-fbdelete\/","url_meta":{"origin":345,"position":4},"title":"MotionBuilder Python Clean Character From Scene with FBDelete()","author":"admin","date":"April 23, 2018","format":false,"excerpt":"This is a script that came about while researching and writing examples for my previous post on FBDelete(). This bit of script will go through a number of constructors within the FBSystem() class. Here is a list of the classes in which our list will go through: fb.FBSystem().Scene.Constraints fb.FBSystem().Scene.Handles fb.FBSystem().Scene.UserObjects\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\/2018\/04\/delete.jpg?fit=768%2C512&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2018\/04\/delete.jpg?fit=768%2C512&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2018\/04\/delete.jpg?fit=768%2C512&resize=700%2C400 2x"},"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":345,"position":5},"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: [code language=\"python\"] from pyfbsdk import * lSystem\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":[]}],"_links":{"self":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/345"}],"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=345"}],"version-history":[{"count":3,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":467,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/345\/revisions\/467"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media\/346"}],"wp:attachment":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}