# Grasshopper/python - reference objects dynamically/load all objects

**URL:** <https://discourse.mcneel.com/t/grasshopper-python-reference-objects-dynamically-load-all-objects/194547>\
**Category:** Grasshopper Developer\
**Tags:** windows, ghpython, python\
**Created:** [November 8, 2024, 10:04am UTC](https://discourse.mcneel.com/t/grasshopper-python-reference-objects-dynamically-load-all-objects/194547 "2024-11-08T10:04:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawel](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pawel/32/732861_2.png) [@pawel](https://discourse.mcneel.com/u/pawel)\
**Post date:** [November 8, 2024, 10:04am UTC](https://discourse.mcneel.com/t/grasshopper-python-reference-objects-dynamically-load-all-objects/194547/1 "2024-11-08T10:04:10Z")

</div>

Dear all,

Could someone help me writing a part of a python script inside grasshopper?

I would like to load all text data from a file - annotations, leaders, object names, text objects etc. into a script.

Why?  
I would like then extract text from it (leaving special text fields like "_%\<ObjectName(“bd37e2d8-9a8b-4254-99f6-b3e30c8b9e7d”)\>%"_) along with its GUID. This way I can export everything to an excel file for further check/translation and other tasks (filtering, checking consistency among all layouts etc.).  
Final step would be to load back in the modified data and reassign it to the objects by following its GUID.

Anyone?

PS: I tried rhinoscriptsyntax, but obviously it doesn’t work in GH  
PS2: Yes, there are elefront and human plugins, but I would like to keep everything inside a script  
PS3: I will share the end result of course.

---

<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:** [November 8, 2024, 10:19am UTC](https://discourse.mcneel.com/t/grasshopper-python-reference-objects-dynamically-load-all-objects/194547/2 "2024-11-08T10:19:41Z")

</div>

> [@pawel](#):
>
> I tried rhinoscriptsyntax, but obviously it doesn’t work in GH

It works just fine, but you might need to set the script context to the Rhino document:

> [@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

It would probably also help to [provide more specific information/requirements](https://discourse.mcneel.com/t/help-us-help-you/50034), and a test file to work with 🙂

---

<div class="post-metadata">

**Author:** ![pawel](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pawel/32/732861_2.png) [@pawel](https://discourse.mcneel.com/u/pawel)\
**Post date:** [November 8, 2024, 10:32am UTC](https://discourse.mcneel.com/t/grasshopper-python-reference-objects-dynamically-load-all-objects/194547/3 "2024-11-08T10:32:10Z")

</div>

It works! You are a life-saver!

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/3/2/2/32247b5190f71f706a92f640b6c359eb65fd3350.png)

---

<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:** [November 8, 2024, 10:42am UTC](https://discourse.mcneel.com/t/grasshopper-python-reference-objects-dynamically-load-all-objects/194547/4 "2024-11-08T10:42:54Z")

</div>

Haha, no worries. Glad it was such a simple fix.
