# Derive access to Rhino object from GH

**URL:** <https://discourse.mcneel.com/t/derive-access-to-rhino-object-from-gh/146301>\
**Category:** Scripting\
**Tags:** script, mac, python, scripting\
**Created:** [August 10, 2022, 8:30am UTC](https://discourse.mcneel.com/t/derive-access-to-rhino-object-from-gh/146301 "2022-08-10T08:30:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadovshikov](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/sadovshikov/32/519935_2.png) [@sadovshikov](https://discourse.mcneel.com/u/sadovshikov)\
**Post date:** [August 10, 2022, 8:30am UTC](https://discourse.mcneel.com/t/derive-access-to-rhino-object-from-gh/146301/1 "2022-08-10T08:30:06Z")

</div>

Hi! I launch the same snippet of a code in the Rhino Python Editor and in the gh Python script editor component, for Rhino it works well whereas running it in Grasshopper it returns None. What I do wrong with gh

```auto
import rhinoscriptsyntax as rs
obj_id = rs.GetObject("Object", 8+16, True, True)
rh_obj = rs.coercerhinoobject(obj_id, True, True)
print rh_obj.Attributes

```

---

<div class="post-metadata">

**Author:** ![AndersDeleuran](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andersdeleuran/32/476683_2.png) [@AndersDeleuran](https://discourse.mcneel.com/u/AndersDeleuran)\
**Post date:** [August 10, 2022, 8:32am UTC](https://discourse.mcneel.com/t/derive-access-to-rhino-object-from-gh/146301/2 "2022-08-10T08:32:34Z")

</div>

You need to change the scriptcontext when targeting the Rhino document from a GHPython script. See this post for a quick example:

> [@Create linear / rectangular lights in grasshopper!](https://discourse.mcneel.com/t/create-linear-rectangular-lights-in-grasshopper/86291/9):
>
> Hi guys. If you want to fiddle with the Rhino document from GHPython, you must explicitly set the script context to target the Rhino document. Here’s one approach: import Rhino as rc import scriptcontext as sc import rhinoscriptsyntax as rs # Set context to Rhino document and disable redraw sc.doc = rc.RhinoDoc.ActiveDoc rs.EnableRedraw(False) # Fiddle with the Rhino document # Set context back to Grasshopper rs.EnableRedraw(True) sc.doc = ghdoc
