{"id":365,"date":"2017-06-12T15:03:49","date_gmt":"2017-06-12T19:03:49","guid":{"rendered":"http:\/\/www.vicdebaie.com\/blog\/?p=365"},"modified":"2017-11-06T09:16:50","modified_gmt":"2017-11-06T14:16:50","slug":"create-a-marker-with-a-random-generated-rgb-color","status":"publish","type":"post","link":"http:\/\/www.vicdebaie.com\/blog\/create-a-marker-with-a-random-generated-rgb-color\/","title":{"rendered":"Generate a random colored Marker through MotionBuilder Python Scripting"},"content":{"rendered":"<p><img data-attachment-id=\"368\" data-permalink=\"http:\/\/www.vicdebaie.com\/blog\/create-a-marker-with-a-random-generated-rgb-color\/rainbow\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/06\/rainbow.jpg?fit=972%2C480\" data-orig-size=\"972,480\" 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\/2017\/06\/rainbow.jpg?fit=300%2C148\" data-large-file=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/06\/rainbow.jpg?fit=678%2C335\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/06\/rainbow.jpg?resize=678%2C335\" alt=\"\" width=\"678\" height=\"335\" class=\"aligncenter size-full wp-image-368\" srcset=\"https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/06\/rainbow.jpg?w=972 972w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/06\/rainbow.jpg?resize=300%2C148 300w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/06\/rainbow.jpg?resize=768%2C379 768w, https:\/\/i0.wp.com\/www.vicdebaie.com\/blog\/wp-content\/uploads\/2017\/06\/rainbow.jpg?resize=810%2C400 810w\" sizes=\"(max-width: 678px) 100vw, 678px\" data-recalc-dims=\"1\" \/><\/p>\n<p>It&#8217;s been awhile since I have posted, things have been really busy between working towards E3 and being a new dad.<\/p>\n<p>I thought I would do a really simple posting that was a lot of fun to figure out. \ud83d\ude42<\/p>\n<p>Below is a script for creating a Marker\/Helper\/Null in Motionbuilder, I posted how to do this before but this time I was able to figure out how to have the Marker show up with a randomly generated color. Python Scripting is awesome. \ud83d\ude42<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfrom pyfbsdk import *\r\nfrom pyfbsdk_additions import *\r\n## This is needed to generate the random numbers\r\nfrom random import *\r\n\r\n## Define Helper's Random Color with random() \r\n'''\r\nThis will randomly generate a number between 0 and 1. When we use random(1, 100), python will randomly generate numbers between 1 and 100. The RGB values we are looking for exist between 0 and 1 so random() will do just fine.\r\n'''\r\nlR = random()\r\nlG = random()\r\nlB = random()\r\n\r\n## Create Helper\r\nlHelper = FBModelMarker('Helper_Mark 1')\r\nlHelper.Show = True\r\nlHelper.Size = 1000\r\nlHelper.PropertyList.Find('LookUi').Data = 1\r\n## Set the color for the helper using our random generated numbers defined above\r\nlHelper.Color = FBColor(lR,lG,lB)\r\n\r\n## let's print the values so we can then compare them to the RGB values within the &quot;Resources&quot; window under &quot;Properties&quot;\r\nprint lR, lG, lB\r\n<\/pre>\n<p>That&#8217;s really it. You can see that the values printed within the MotionBulder&#8217;s Python Console window are rounded up to the second decimal point and then set as the Marker&#8217;s RGB Color value.<\/p>\n<p>I hope this helps.<\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>It&#8217;s been awhile since I have posted, things have been really busy between working towards E3 and being a new dad. I thought I would do a really simple posting that was a lot of fun to figure out. \ud83d\ude42 Below is a script for creating a Marker\/Helper\/Null in Motionbuilder, I posted how to do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":368,"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\/06\/rainbow.jpg?fit=972%2C480","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8pltq-5T","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":566,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-parent-constraint-tool\/","url_meta":{"origin":365,"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":77,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-where-to-start\/","url_meta":{"origin":365,"position":1},"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":[]},{"id":90,"url":"http:\/\/www.vicdebaie.com\/blog\/creating-a-marker-or-helper\/","url_meta":{"origin":365,"position":2},"title":"Creating A Marker or &#8220;Helper&#8221;","author":"admin","date":"February 7, 2017","format":false,"excerpt":"Creating a simple marker in MotionBuilder using Python scripting. So here was a script that took some time for me. Changing the Look of the marker through Python had me stumped (luckily I had a friend who could help). \u00a0 Changing the color of the null\/model was a long 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\/02\/1D96D7E4-D9D3-4489-9424-5F373A051926-15581-00001FEA536102C2_tmp.png?fit=337%2C220&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":365,"position":3},"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":645,"url":"http:\/\/www.vicdebaie.com\/blog\/motionbuilder-python-a-better-way-to-create-constraints\/","url_meta":{"origin":365,"position":4},"title":"MotionBuilder Python &#8211; A Better Way To Create Constraints","author":"admin","date":"November 14, 2018","format":false,"excerpt":"Update Thanks to\u00a0kilianeczka\u00a0for the heads up, there is even an EASIER easy way to create a constraint using MotionBuilder and Python [code language=\"python\"] import pyfbsdk as fb fb.FBConstraintManager().TypeCreateConstraint('Parent\/Child') [\/code] This omits the need to find the number of constraints and then search all the constraints for one that has 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\/11\/Think^_Is_There_a_Better_Way_to_Do_it^_-_NARA_-_534256.jpg?fit=400%2C204&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":365,"position":5},"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":[]}],"_links":{"self":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/365"}],"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=365"}],"version-history":[{"count":5,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/365\/revisions"}],"predecessor-version":[{"id":372,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/posts\/365\/revisions\/372"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media\/368"}],"wp:attachment":[{"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/media?parent=365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/categories?post=365"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.vicdebaie.com\/blog\/wp-json\/wp\/v2\/tags?post=365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}