Use Rhino.Python to manipulate the Gumball?

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
    comm_str="_GumballRelocate {} {} {}".format(pick_pt,x_pt,y_pt)
    for obj_id in obj_ids:

If the rs.Redraw() line is commented out, only the first object in the list gets its gumball relocated.

Hi @Helvetosaur,

Sorry for the late reply.

I don’t see anyway around this at this time.

– Dale