Is it possible to use Rhino.Python to manipulate the Gumball location? The reason for this question is that I am generating some geometry from a Python script, however the Gumball is not located at the centroid of the geometry when I select the object. I would like to calculate the centroid and then place the Gumball at the centroid. Otherwise, I have the extra steps of manually relocating the Gumball from within Rhino.
Hi @habudg,
There is no SDK access to Rhino’s internal Gumball. The best you can do, at the moment, is to script one of the Gumball-related commands.
– Dale
Ok. Not sure if it’s possible, but it would be nice to have this a part of the API at some point.
Hi @dale,
I attempted to do this and I ran into an interesting issue - if one is looping through multiple objects to relocate the gumball on each one, it seems that one needs to redraw the screen between objects, otherwise it doesn’t work - only the first object gets relocated. Here is the script:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def RelocateObjsGumballToPoint():
obj_ids=rs.GetObjects("Select objects to relocate gumball",preselect=True)
if not obj_ids: return
pick_pt=rs.GetPoint("Pick point to relocate object gumball centers")
if not pick_pt: return
x_pt=pick_pt+Rhino.Geometry.Vector3d(1,0,0)
y_pt=pick_pt+Rhino.Geometry.Vector3d(0,1,0)
comm_str="_GumballRelocate {} {} {}".format(pick_pt,x_pt,y_pt)
rs.EnableRedraw(False)
rs.UnselectAllObjects()
for obj_id in obj_ids:
rs.SelectObject(obj_id)
rs.Command(comm_str,False)
rs.Redraw()
rs.UnselectObject(obj_id)
RelocateObjsGumballToPoint()
If the rs.Redraw() line is commented out, only the first object in the list gets its gumball relocated.