Page 1 of 1
setColor In Python Script
Posted: Tue Dec 04, 2012 2:33 pm
by bradh
I am looking for some example text in how the color of a body can me changed in a python script. The body was created using:
block.addDisplayGeometry("PART.obj")
I have tried using the DisplayGeometry class under openSim to no avail.
Thanks!
Brad
Re: setColor In Python Script
Posted: Thu Dec 06, 2012 10:44 am
by aymanh
Hi Brad,
The distribution include a script to set color in the GUI. If you want to set the color from a generic Python script you'd use the following code snippet:
Code: Select all
pelvis = model.getBodySet().get('pelvis')
displayer = pelvis.getDisplayer()
geometrySet = displayer.getGeometrySet()
gi = geometrySet.get(0)
gi.setColor([1, 0, .5])
Hope this helps,
-Ayman
Re: setColor In Python Script
Posted: Thu Dec 06, 2012 2:18 pm
by bradh
Ayman,
Thanks! Works great. IMHO, this would be a good example for documentation of the python scripting. While "color" is a bit secondary, your code snippet maps/keys well to the doxygen documentation hierarchy.
Brad