{"id":42,"date":"2016-04-01T15:31:59","date_gmt":"2016-04-01T22:31:59","guid":{"rendered":"http:\/\/blog.stevenzaharakis.com\/?p=42"},"modified":"2016-07-15T03:22:53","modified_gmt":"2016-07-15T10:22:53","slug":"been-learning-some-motionbuilder-python-api","status":"publish","type":"post","link":"https:\/\/blog.stevenzaharakis.com\/index.php\/2016\/04\/01\/been-learning-some-motionbuilder-python-api\/","title":{"rendered":"Been learning some Motionbuilder Python API"},"content":{"rendered":"<p>And let me tell you it is frustrating as hell&#8230;. \u00a0something as simple as just trying to connect the Translate Y of one attribute to another is like an insane amount of code. \u00a0It literally makes you want to throw a chair at someone. \u00a0Here&#8217;s a nice example for that simple connection:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:python decode:true \" >lConstraintRelation = FBConstraintRelation('Test')\r\nlConstraintRelation.Active = True\r\n\r\nA = FBModelNull('NullA')\r\nA.Show= True\r\n\r\nB = FBModelNull('NullB')\r\nB.Show= True\r\n\r\nsourceBox = lConstraintRelation.SetAsSource (A)\r\nconvertBoxV2N = lConstraintRelation.CreateFunctionBox('Converters', 'Vector to Number')\r\ntargetBox = lConstraintRelation.ConstrainObject (B)\r\nconvertBoxN2V = lConstraintRelation.CreateFunctionBox('Converters', 'Number to Vector')\r\n\r\n#Link up the constraints, connecting Source Translation to converterBox Vector to Number first\r\n#Then connecting convertBoxV2N to converterbox Number to Vector, then finally\r\n#connecting just the Translate Y of converterBoxN2V to our Target Translate\r\nOUT = FindAnimationNode (sourceBox.AnimationNodeOutGet(), 'Translation')\r\nIN = FindAnimationNode (convertBoxV2N.AnimationNodeInGet(), 'V')\r\nif OUT and IN:\r\nprint \"Success1\"\r\nFBConnect(OUT, IN)\r\n\r\nOUT = FindAnimationNode (convertBoxV2N.AnimationNodeOutGet(), 'Y')\r\nIN = FindAnimationNode (convertBoxN2V.AnimationNodeInGet(), 'Y')\r\nif OUT and IN:\r\nprint \"Success2\"\r\nFBConnect(OUT, IN)\r\n\r\nOUT = FindAnimationNode (convertBoxN2V.AnimationNodeOutGet(), 'Result')\r\nIN = FindAnimationNode (targetBox.AnimationNodeInGet(), 'Translation')\r\nif OUT and IN:\r\nprint \"Success3\"\r\nFBConnect(OUT, IN)<\/pre>\n<p><\/br><br \/>\nHope this helps someone!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>And let me tell you it is frustrating as hell&#8230;. \u00a0something as simple as just trying to connect the Translate Y of one attribute to another is like an insane amount of code. \u00a0It literally makes you want to throw a chair at someone. \u00a0Here&#8217;s a nice example for that simple connection: &nbsp; lConstraintRelation = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_links_to":"","_links_to_target":""},"categories":[8,7],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/posts\/42"}],"collection":[{"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":8,"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/posts\/42\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.stevenzaharakis.com\/index.php\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}