# Use Rhino.Python to manipulate the Gumball?

**URL:** <https://discourse.mcneel.com/t/use-rhino-python-to-manipulate-the-gumball/114156>\
**Category:** Scripting\
**Tags:** python\
**Created:** [December 9, 2020, 6:52pm UTC](https://discourse.mcneel.com/t/use-rhino-python-to-manipulate-the-gumball/114156 "2020-12-09T18:52:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![habudg](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/habudg/32/758480_2.png) [@habudg](https://discourse.mcneel.com/u/habudg)\
**Post date:** [December 9, 2020, 6:52pm UTC](https://discourse.mcneel.com/t/use-rhino-python-to-manipulate-the-gumball/114156/1 "2020-12-09T18:52:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [December 9, 2020, 7:02pm UTC](https://discourse.mcneel.com/t/use-rhino-python-to-manipulate-the-gumball/114156/2 "2020-12-09T19:02:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![habudg](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/habudg/32/758480_2.png) [@habudg](https://discourse.mcneel.com/u/habudg)\
**Post date:** [December 9, 2020, 7:09pm UTC](https://discourse.mcneel.com/t/use-rhino-python-to-manipulate-the-gumball/114156/3 "2020-12-09T19:09:32Z")

</div>

Ok. Not sure if it’s possible, but it would be nice to have this a part of the API at some point.

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [February 25, 2023, 6:05pm UTC](https://discourse.mcneel.com/t/use-rhino-python-to-manipulate-the-gumball/114156/4 "2023-02-25T18:05:43Z")

</div>

> [@dale](#):
>
> The best you can do, at the moment, is to script one of the Gumball-related commands.

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:

```python
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.

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [March 13, 2023, 8:04pm UTC](https://discourse.mcneel.com/t/use-rhino-python-to-manipulate-the-gumball/114156/5 "2023-03-13T20:04:55Z")

</div>

Hi @Helvetosaur,

Sorry for the late reply.

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

– Dale
