# Replacing existing text through python script?

**URL:** <https://discourse.mcneel.com/t/replacing-existing-text-through-python-script/200190>\
**Category:** Scripting\
**Tags:** mac, python, rhino7\
**Created:** [February 24, 2025, 12:19pm UTC](https://discourse.mcneel.com/t/replacing-existing-text-through-python-script/200190 "2025-02-24T12:19:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maurice\_Lukié](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/maurice_luki%C3%A9/32/653090_2.png) [@Maurice\_Lukié](https://discourse.mcneel.com/u/Maurice_Luki%C3%A9)\
**Post date:** [February 24, 2025, 12:19pm UTC](https://discourse.mcneel.com/t/replacing-existing-text-through-python-script/200190/1 "2025-02-24T12:19:07Z")

</div>

Hey there,

so my problem is that I have an existing text in my rhino document (Bauherr: Max Mustermann), that I want to replace through grasshopper via cvs. file that has the actual name, that I want to change.

I already wrote a script that finds the new name from the .cvs file and should change the existing name (Max Mustermann) with the name from the .cvs.  
Going through a lot of debugging, rhino is still not able to find the ‘Text’ in my document, even though it’s the only object in the whole project:

‘Runtime error (MissingMemberException): ‘CustomTable’ object has no attribute ‘GetObjectList’’

Is there any way to get Rhino to find my text-properties via script or component ?

thank you in advance!

---

<div class="post-metadata">

**Author:** ![James\_Parrott](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/james_parrott/32/713265_2.png) [@James\_Parrott](https://discourse.mcneel.com/u/James_Parrott)\
**Post date:** [February 24, 2025, 2:29pm UTC](https://discourse.mcneel.com/t/replacing-existing-text-through-python-script/200190/2 "2025-02-24T14:29:05Z")

</div>

```auto
import scriptcontext as sc
import Rhino
import rhinoscriptsyntax as rs

if new_text is None:
    new_text = "Bauherr: Feathers McGraw"

def set_text(to: str) -> None:
    # https://developer.rhino3d.com/api/RhinoScriptSyntax/#selection-ObjectsByType
    guids = rs.ObjectsByType(0) 
    for guid in guids:
        # obj = sc.doc.Objects.Find(guid)
        geom = sc.doc.Objects.FindGeometry(guid)
        if geom. __class__ not in [Rhino.Geometry.TextEntity]:
            continue
        rs.TextObjectText(guid,to)

try:
    sc.doc = Rhino.RhinoDoc.ActiveDoc
    set_text(new_text)
except BaseException as e:
    raise e
finally:
    sc.doc = ghdoc

```

---

<div class="post-metadata">

**Author:** ![Maurice\_Lukié](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/maurice_luki%C3%A9/32/653090_2.png) [@Maurice\_Lukié](https://discourse.mcneel.com/u/Maurice_Luki%C3%A9)\
**Post date:** [March 17, 2025, 9:25am UTC](https://discourse.mcneel.com/t/replacing-existing-text-through-python-script/200190/3 "2025-03-17T09:25:28Z")

</div>

Thank you very much! That helped me and the script was running with one value changing through the script.

Since I added a few more values into the .csv and the script, that should be changed, i immediately got the same error again:

Runtime error (MissingMemberException): ‘CustomTable’ object has no attribute ‘GetObjectList’

Traceback:  
line 1008, in ObjectsByType, “/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR\_Python.rhp/RssLib/rhinoscript/selection.py”  
line 53, in set\_text, “”  
line 73, in ersetze\_text\_in\_rhino, “”  
line 79, in script

Even though the Text-Objects that should be changed have the same type, rhino is not valuing them as such.  
I already tried the ‘guids = rs.ObjectsByType(0)’ to prevent that from happening, but I still can’t figure out how rhino is not detecting/changing the values/texts, even though they should be type 512 anyway ?

im loosing my mind over this haha, pls send help 😃

---

<div class="post-metadata">

**Author:** ![James\_Parrott](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/james_parrott/32/713265_2.png) [@James\_Parrott](https://discourse.mcneel.com/u/James_Parrott)\
**Post date:** [March 17, 2025, 11:11am UTC](https://discourse.mcneel.com/t/replacing-existing-text-through-python-script/200190/4 "2025-03-17T11:11:59Z")

</div>

You’re welcome Maurice.

Can you attach a .3dm file and a .gh file showing the problem?
