It’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. 🙂
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. 🙂
from pyfbsdk import * from pyfbsdk_additions import * ## This is needed to generate the random numbers from random import * ## Define Helper's Random Color with random() ''' This 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. ''' lR = random() lG = random() lB = random() ## Create Helper lHelper = FBModelMarker('Helper_Mark 1') lHelper.Show = True lHelper.Size = 1000 lHelper.PropertyList.Find('LookUi').Data = 1 ## Set the color for the helper using our random generated numbers defined above lHelper.Color = FBColor(lR,lG,lB) ## let's print the values so we can then compare them to the RGB values within the "Resources" window under "Properties" print lR, lG, lB
That’s really it. You can see that the values printed within the MotionBulder’s Python Console window are rounded up to the second decimal point and then set as the Marker’s RGB Color value.
I hope this helps.