{"id":739,"date":"2019-11-18T16:17:15","date_gmt":"2019-11-18T21:17:15","guid":{"rendered":"http:\/\/www.vicdebaie.com\/blog\/?p=739"},"modified":"2019-11-18T16:17:23","modified_gmt":"2019-11-18T21:17:23","slug":"motionbuilder-python-choose-interaction-mode-tool","status":"publish","type":"post","link":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-choose-interaction-mode-tool\/","title":{"rendered":"MotionBuilder Python -Choose Interaction Mode Tool"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-attachment-id=\"742\" data-permalink=\"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-choose-interaction-mode-tool\/guid-1f064d55-de9a-4005-9179-80aaaad4b3aa\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/GUID-1F064D55-DE9A-4005-9179-80AAAAD4B3AA.png?fit=356%2C202\" data-orig-size=\"356,202\" 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;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\/GUID-1F064D55-DE9A-4005-9179-80AAAAD4B3AA.png?fit=300%2C170\" data-large-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/GUID-1F064D55-DE9A-4005-9179-80AAAAD4B3AA.png?fit=356%2C202\" decoding=\"async\" loading=\"lazy\" width=\"356\" height=\"202\" src=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/GUID-1F064D55-DE9A-4005-9179-80AAAAD4B3AA.png?resize=356%2C202\" alt=\"\" class=\"wp-image-742\" srcset=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/GUID-1F064D55-DE9A-4005-9179-80AAAAD4B3AA.png?w=356 356w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/GUID-1F064D55-DE9A-4005-9179-80AAAAD4B3AA.png?resize=300%2C170 300w\" sizes=\"(max-width: 356px) 100vw, 356px\" data-recalc-dims=\"1\" \/><\/figure><\/div>\n\n\n\n<p>On the <a href=\"https:\/\/forums.autodesk.com\/t5\/motionbuilder-forum\/hotkey-to-switch-between-interaction-mode\/td-p\/8135096\">Discrete Motionbuilder Forum there was a discussion on how to use python the change Motionbuilder&#8217;s InteractionMode<\/a>.<\/p>\n\n\n\n<p>Sunil (the person that started the post) was able to figure out a solution to his original post and I suggested that a hotkey could be setup to trigger the script via the ActionScript.Txt file(more on that in  later post).<\/p>\n\n\n\n<p>The script made me quickly realize that I often jump onto other people&#8217;s systems to help them out with any MotionBuilder problem they maybe facing. More often than not they are using Maya or 3dmax InteractionModes and I have to change them &#8220;MotionBuilder&#8221; so that I may work comfortably.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img data-attachment-id=\"740\" data-permalink=\"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-choose-interaction-mode-tool\/swithcinteractionmodetool\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/SwithcInteractionModeTool.png?fit=171%2C215\" data-orig-size=\"171,215\" 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;0&quot;}\" data-image-title=\"SwithcInteractionModeTool\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/SwithcInteractionModeTool.png?fit=171%2C215\" data-large-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/SwithcInteractionModeTool.png?fit=171%2C215\" decoding=\"async\" loading=\"lazy\" width=\"171\" height=\"215\" src=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/SwithcInteractionModeTool.png?resize=171%2C215\" alt=\"\" class=\"wp-image-740\" data-recalc-dims=\"1\"\/><\/figure><\/div>\n\n\n\n<p> I wrote a very simple script that will generate a tool that lists all InteractionModes and allows you to instantly change them on the fly with a simple single click.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pyfbsdk as fb\nimport pyfbsdk_additions as fba\n\n##Change InteractionMode On List Item Click\ndef DrpDwn_intModeList_CallBack(control, event):\n    ##Change Mode\n    fb.FBActionManager().CurrentInteractionMode = control.Items[control.ItemIndex]\n    ##Update UI To Communicate CurrentInteractionMode\n    interactionMode.Caption = fb.FBActionManager().CurrentInteractionMode\n \n    \n'''\nUI Layout\n'''\ndef PopulateTool(t):    \n    ##Inter Active Mode Label------------------------------------------------------------------------------\n    intModeList = fb.FBLabel()\n    \n    x = fb.FBAddRegionParam(   5, fb.FBAttachType.kFBAttachNone, \"\" )\n    y = fb.FBAddRegionParam(   5, fb.FBAttachType.kFBAttachNone, \"\" )\n    w = fb.FBAddRegionParam( -5, fb.FBAttachType.kFBAttachRight, \"\" )\n    h = fb.FBAddRegionParam(  20, fb.FBAttachType.kFBAttachNone, \"\" )\n    \n    t.AddRegion( \"intModeList\", \"intModeList\", x, y, w, h )\n    t.SetControl( \"intModeList\", intModeList )\n    \n    intModeList.Caption                                 = \"Choose InteractionMode:\"\n    intModeList.Style                                   = fb.FBTextStyle.kFBTextStyleBold\n    intModeList.Justify                                 = fb.FBTextJustify.kFBTextJustifyCenter\n        \n    ##Inter Active Drop Down List------------------------------------------------------------------------------\n    DrpDwn_intModeList                                  = fb.FBList()\n    \n    x = fb.FBAddRegionParam(   0, fb.FBAttachType.kFBAttachLeft, \"intModeList\" )\n    y = fb.FBAddRegionParam(   5, fb.FBAttachType.kFBAttachBottom, \"intModeList\" )\n    w = fb.FBAddRegionParam(  -5, fb.FBAttachType.kFBAttachRight, \"\" )\n    h = fb.FBAddRegionParam( 95, fb.FBAttachType.kFBAttachNone, \"\" )\n    \n    t.AddRegion( \"DrpDwn_intModeList\", \"DrpDwn_intModeList\", x, y, w, h )\n    t.SetControl( \"DrpDwn_intModeList\", DrpDwn_intModeList )\n    \n    DrpDwn_intModeList.MultiSelect                      = False\n    DrpDwn_intModeList.ExtendedSelect                   = False\n    DrpDwn_intModeList.Style                            = fb.FBListStyle.kFBVerticalList\n    \n    ##Generate List And Have The Current InteractiveMode Selected------------------------------------------------------------------------------\n    interactionModes = [ \"MotionBuilder\", \"MotionBuilder Classic\", \"Maya\", \"3ds Max\", \"Lightwave\", \"Softimage\" ]\n    for mode in interactionModes:\n        DrpDwn_intModeList.Items.append(mode)\n        \n        if fb.FBActionManager().CurrentInteractionMode == mode:\n            myMode = interactionModes.index(mode)\n        \n    DrpDwn_intModeList.ItemIndex = myMode\n        \n    DrpDwn_intModeList.OnChange.Add(DrpDwn_intModeList_CallBack)\n        \n    ##Current Inter Active Mode Label------------------------------------------------------------------------------\n    currentMode = fb.FBLabel()\n    x = fb.FBAddRegionParam(   0, fb.FBAttachType.kFBAttachLeft, \"DrpDwn_intModeList\" )\n    y = fb.FBAddRegionParam(   5, fb.FBAttachType.kFBAttachBottom, \"DrpDwn_intModeList\" )\n    w = fb.FBAddRegionParam(   0, fb.FBAttachType.kFBAttachRight, \"\" )\n    h = fb.FBAddRegionParam(  20, fb.FBAttachType.kFBAttachNone, \"\" )\n    \n    t.AddRegion( \"currentMode\", \"currentMode\", x, y, w, h )\n    t.SetControl( \"currentMode\", currentMode )\n    \n    currentMode.Caption                                 = \"Current InteractionMode:\"\n    currentMode.Style                                   = fb.FBTextStyle.kFBTextStyleBold\n    currentMode.Justify                                 = fb.FBTextJustify.kFBTextJustifyLeft\n        \n    ##Current Interactive Mode------------------------------------------------------------------------------\n    global interactionMode\n    interactionMode = fb.FBLabel()\n    \n    x = fb.FBAddRegionParam(   0, fb.FBAttachType.kFBAttachLeft, \"currentMode\" )\n    y = fb.FBAddRegionParam(   5, fb.FBAttachType.kFBAttachBottom, \"currentMode\" )\n    w = fb.FBAddRegionParam(   0, fb.FBAttachType.kFBAttachRight, \"\" )\n    h = fb.FBAddRegionParam(  20, fb.FBAttachType.kFBAttachNone, \"\" )\n    \n    t.AddRegion( \"interactionMode\", \"interactionMode\", x, y, w, h )\n    t.SetControl( \"interactionMode\", interactionMode )\n    \n    interactionMode.Caption                                 = fb.FBActionManager().CurrentInteractionMode\n    interactionMode.Style                                   = fb.FBTextStyle.kFBTextStyleBold\n    interactionMode.Justify                                 = fb.FBTextJustify.kFBTextJustifyCenter\n\n\n    \ndef CreateTool():\n    t               = fba.FBCreateUniqueTool( \"Switch InteractionMode\" )\n    t.MinSizeX      = 160\n    t.MaxSizeX      = 160\n    t.MinSizeY      = 175\n    t.MaxSizeY      = 175\n    \n    PopulateTool(t)\n    fb.ShowTool(t)\n\nCreateTool()\n<\/code><\/pre>\n\n\n\n<p>This was quick script to make but I know it will save me some time and frustration when helping other at their computers.<\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>A quick script that allows the user to change Motionbuilder&#8217;s Interaction Mode with a single click<\/p>\n","protected":false},"author":1,"featured_media":742,"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 -Choose Interaction Mode Tool\n\nA quick way to change InteractionModes with a single click\n\n#Motionbuilder #Ptyhon","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":[14,13,16,15,5],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/11\/GUID-1F064D55-DE9A-4005-9179-80AAAAD4B3AA.png?fit=356%2C202","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8pltq-bV","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":566,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-parent-constraint-tool\/","url_meta":{"origin":739,"position":0},"title":"MotionBuilder Python Parent Constraint Tool","author":"admin","date":"June 18, 2018","format":false,"excerpt":"Here is a quick post to share a tool I created a little while back. It is designed to help to quickly create Parent Constraints between two objects as well as easily allow the user to bake that constraint down. The script can be found HERE and there are a\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_3937.jpg?fit=443%2C364&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":63,"url":"http:\/\/www.vicdebaie.com\/blog\/hello-world-a-k-a-let-us-begin\/","url_meta":{"origin":739,"position":1},"title":"Hello World! &#8211; A.k.a &#8220;Let us begin&#8221;","author":"admin","date":"February 6, 2017","format":false,"excerpt":"Here is my first posting for this experiment - \"the blog\". For the last two weeks I have been mucking around with Python scripting within MotionBuilder. It has been an uphill battle. With the limited resources out there all I can really do is hack away at bits and pieces\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_3934.jpg?fit=526%2C492&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":288,"url":"http:\/\/www.vicdebaie.com\/blog\/getting-information-on-motionbuilders-python-with-dir\/","url_meta":{"origin":739,"position":2},"title":"Getting information on MotionBuilder&#8217;s Python with dir","author":"admin","date":"March 13, 2017","format":false,"excerpt":"Trying to figure how things work in MotionBuilder's Python editor is tough. Google and the SDK Help that comes along with MotionBuilder are great, but there is still more help out there - the \"dir\"! :) What does \"dir\" do? The definition I was able to find is \"It gives\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":175,"url":"http:\/\/www.vicdebaie.com\/blog\/%ef%bb%bfplotting-selected-properties-using-motionbuilders-python\/","url_meta":{"origin":739,"position":3},"title":"\ufeffPlotting selected properties using MotionBuilder&#8217;s Python.","author":"admin","date":"February 17, 2017","format":false,"excerpt":"I ran\u00a0the script I created in \"Animating and setting keys with MotionBuilder's Python Editor\"\u00a0and decided that I would use the scene it creates\u00a0to learn how to plot on selected properties in MotionBuilder's Python Editor. Update: I found a work around for the bug and it is covered in my \"lock-and-plot-selected-properties-using-motionbuilders-python\"\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":190,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-tool-saveit\/","url_meta":{"origin":739,"position":4},"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":711,"url":"http:\/\/www.vicdebaie.com\/blog\/using-motionbuilder-python-to-cast-real-time-shadows\/","url_meta":{"origin":739,"position":5},"title":"Using MotionBuilder Python To Cast Real-Time Shadows","author":"admin","date":"September 18, 2019","format":false,"excerpt":"Using Python To Quickly Add A Real Time Shadow To Your MotionBuilder Scene.","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\/09\/ShadowCube.png?fit=1157%2C526&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/09\/ShadowCube.png?fit=1157%2C526&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/09\/ShadowCube.png?fit=1157%2C526&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2019\/09\/ShadowCube.png?fit=1157%2C526&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/739"}],"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=739"}],"version-history":[{"count":4,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/739\/revisions"}],"predecessor-version":[{"id":746,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/739\/revisions\/746"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media\/742"}],"wp:attachment":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media?parent=739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/categories?post=739"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/tags?post=739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}