{"id":805,"date":"2021-03-23T13:05:32","date_gmt":"2021-03-23T17:05:32","guid":{"rendered":"http:\/\/www.vicdebaie.com\/blog\/?p=805"},"modified":"2021-04-28T08:44:50","modified_gmt":"2021-04-28T12:44:50","slug":"write-take-info-to-text-file","status":"publish","type":"post","link":"http:\/\/www.vicdebaie.com\/blog\/write-take-info-to-text-file\/","title":{"rendered":"Write Take info To Text File"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large is-resized\"><a href=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/03\/Writing_on_the_whiteboard-1.jpg\"><img data-attachment-id=\"807\" data-permalink=\"http:\/\/www.vicdebaie.com\/blog\/write-take-info-to-text-file\/writing-on-the-whiteboard-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/03\/Writing_on_the_whiteboard-1.jpg?fit=853%2C640\" data-orig-size=\"853,640\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;2&quot;,&quot;credit&quot;:&quot;Santeri Viinam\\u00e4ki&quot;,&quot;camera&quot;:&quot;ONEPLUS A3003&quot;,&quot;caption&quot;:&quot;Writing on the whiteboard&quot;,&quot;created_timestamp&quot;:&quot;1471958622&quot;,&quot;copyright&quot;:&quot;Santeri Viinam\\u00e4ki&quot;,&quot;focal_length&quot;:&quot;4.26&quot;,&quot;iso&quot;:&quot;400&quot;,&quot;shutter_speed&quot;:&quot;0.04&quot;,&quot;title&quot;:&quot;Writing on the whiteboard&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\/2021\/03\/Writing_on_the_whiteboard-1.jpg?fit=300%2C225\" data-large-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/03\/Writing_on_the_whiteboard-1.jpg?fit=678%2C509\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/03\/Writing_on_the_whiteboard-1.jpg?resize=213%2C160\" alt=\"\" class=\"wp-image-807\" width=\"213\" height=\"160\" srcset=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/03\/Writing_on_the_whiteboard-1.jpg?w=853 853w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/03\/Writing_on_the_whiteboard-1.jpg?resize=300%2C225 300w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/03\/Writing_on_the_whiteboard-1.jpg?resize=768%2C576 768w\" sizes=\"(max-width: 213px) 100vw, 213px\" data-recalc-dims=\"1\" \/><\/a><\/figure><\/div>\n\n\n\n<p>In one of my previous posts a user left a comment asking &#8220;How can I print Take information out to a .txt file&#8221;. I figured that was as good as any topic to cover so here it is. \ud83d\ude42<\/p>\n\n\n\n<p>The script below will look at the open Motionbuilder scene&#8217;s name and file path &#8211; using that information it will create a new &#8216;.txt&#8217; file and write some information.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom pyfbsdk import *\n\ndef WriteTakeInfo():\n    ##Find The Scene's File Name And Use It To Create A .txt File\n    mytextFile=FBApplication().FBXFileName&#x5B;:-4]+&quot;-TakeInfo.txt&quot;\n    \n    ##Create And Open The New .txt File So That It May Be Wrote To\n    textFile=open(mytextFile,&quot;w&quot;)\n   \n    ##Create A List \n    sceneTakes=&#x5B;]\n    ##Go Through All Takes Within The Open Scene\n    for myTake in FBSystem().Scene.Takes:\n        ##For Each Take Create A Dictionary\n        ##Store Take Name, Frame Count, Length, Start Time and Stop Time\n        takeInfo={\n        &quot;Name&quot;:myTake.Name,\n        &quot;Frames&quot;:myTake.LocalTimeSpan.GetDuration().GetFrame(),\n        &quot;Seconds&quot;:myTake.LocalTimeSpan.GetDuration().GetSecondDouble(),\n        &quot;StartFrame&quot;:myTake.LocalTimeSpan.GetStart().GetFrame(),\n        &quot;EndFrame&quot;:myTake.LocalTimeSpan.GetStop().GetFrame()\n        }\n        ##Store The Dictionary Into Our List\n        sceneTakes.extend(&#x5B;takeInfo])\n        \n    ##Go Through Each Dictionary In Our List And Write The Info To Our .txt File    \n    for dict in sceneTakes:\n        textFile.write(&quot;Take Name:&quot; % dict&#x5B;&quot;Name&quot;])\n        textFile.write('\\n')\n        textFile.write(&quot;Number of Frames:&quot; % dict&#x5B;&quot;Frames&quot;])\n        textFile.write('\\n')\n        textFile.write(&quot;Length of Time in Seconds:&quot; % dict&#x5B;&quot;Seconds&quot;])\n        textFile.write('\\n')\n        textFile.write(&quot;Start Frame:&quot; % dict&#x5B;&quot;StartFrame&quot;])\n        textFile.write('\\n')\n        textFile.write(&quot;End Frame:&quot; % dict&#x5B;&quot;EndFrame&quot;])\n        textFile.write('\\n')\n        textFile.write(&quot;-----------------------------------------------------------------&quot;)\n        textFile.write('\\n')\n    \n    ##Close The .txt File\n    textFile.close()\n<\/pre><\/div>\n\n\n<p>I am sure my string formating could be alot better, but this gets the job done.<\/p>\n\n\n\n<p>I hope this helps.<\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Write out take information to a .txt file using MotionBuilder Python<\/p>\n","protected":false},"author":1,"featured_media":807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"A user asked \"How can I write out take info to a .txt file?\". I thought that was as good of a topic as any to post about. :)\n\n#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":[12],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2021\/03\/Writing_on_the_whiteboard-1.jpg?fit=853%2C640","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8pltq-cZ","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":190,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-tool-saveit\/","url_meta":{"origin":805,"position":0},"title":"MotionBuilder Python Tool &#8220;SaveIt&#8221;","author":"admin","date":"February 12, 2017","format":false,"excerpt":"Here is a script\/tool I created for MotionBuilder using Python. \u00a0This tool will\u00a0do an incremental save of your scene. Why? Incremental saves are amazingly useful, I thought a tool that automates the process down to one click would be fun. A big thanks goes out to my college Raphael Lappiere\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\/SaveIt_tool.jpg?fit=600%2C220&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":569,"url":"http:\/\/www.vicdebaie.com\/blog\/pick-favorite-object-with-motionbuilder-python\/","url_meta":{"origin":805,"position":1},"title":"Pick Favorite Object With MotionBuilder Python","author":"admin","date":"June 19, 2018","format":false,"excerpt":"Here is a Tool that I quickly built while working with a lot of controllers, nulls and objects that were either on top of one and other or very close. I could of used groups and what not but I had more fun taking a few minutes to write this\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\/06\/a-few-of-my-favorite-things-jan-7-2011.jpg?fit=587%2C315&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":469,"url":"http:\/\/www.vicdebaie.com\/blog\/running-a-python-script-on-every-motionbuilder-file-within-a-directory\/","url_meta":{"origin":805,"position":2},"title":"Running a Python Script On Every MotionBuilder File Within A Directory","author":"admin","date":"March 6, 2018","format":false,"excerpt":"It's been awhile since I have posted, We are approaching launch of my next game tittle and now that I have a free moment I thought I would demonstrate how to run a python script on multiple \".fbx\" files. All the \".fbx\" files for this demo will exist within the\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\/03\/Possibility.jpg?fit=960%2C627&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2018\/03\/Possibility.jpg?fit=960%2C627&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2018\/03\/Possibility.jpg?fit=960%2C627&resize=700%2C400 2x"},"classes":[]},{"id":276,"url":"http:\/\/www.vicdebaie.com\/blog\/saving-motionbuilder-character-animation-with-python\/","url_meta":{"origin":805,"position":3},"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":739,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-choose-interaction-mode-tool\/","url_meta":{"origin":805,"position":4},"title":"MotionBuilder Python -Choose Interaction Mode Tool","author":"admin","date":"November 18, 2019","format":false,"excerpt":"A quick script that allows the user to change Motionbuilder's Interaction Mode with a single click","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\/2019\/11\/GUID-1F064D55-DE9A-4005-9179-80AAAAD4B3AA.png?fit=356%2C202&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":77,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-where-to-start\/","url_meta":{"origin":805,"position":5},"title":"MotionBuilder Python &#8211; Where to start","author":"admin","date":"February 6, 2017","format":false,"excerpt":"Finding information for Python scripting in MotionBuilder can be an uphill battle. Here is a list of some of the resources that I have been able to find (thanks google). A lot of the listed links have valuable scripts in which one can hack through and decipher what each line\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\/16697171583_7c33584c4b.jpg?fit=500%2C333&resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/805"}],"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=805"}],"version-history":[{"count":2,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/805\/revisions"}],"predecessor-version":[{"id":811,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/805\/revisions\/811"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media\/807"}],"wp:attachment":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media?parent=805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/categories?post=805"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/tags?post=805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}