Documentusertext GH VBScript

Hi all,

i’m trying to find a way in the grasshopper VBScript componant to set and get documentusertext into/from the rhino document.

I’m looking for something similar like the rhino commands “setdocumentusertext” and “getdocumentusertext”

Can someone help me with a small example?

Many thanks!

Hi all,

I found this UserData class and I think this is what I am looking for. The problem is, that I still can’t get a simple example working. What would really help me is if someone has a small example how to set and get a value from rhinos document usertexts with the grasshopper vbscript componant.

https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_Custom_UserData.htm

Many thanks!

See of the attached is helpful.

document_usertext.gh (6.0 KB)

– Dale

1 Like

Is there a method for retreiving document_usertext from a file other than the active document?

Hi @dale
How can this be done in Python?

I tried this method:

But this gives me the folowing error:

Runtime error (NotSupportedException): This type of object is not supported in Grasshopper, so this Python script cannot create it. You might want to use ‘scriptcontext.doc = Rhino.RhinoDoc.ActiveDoc’ to use the Rhino doc, instead? If you do, remember to restore it: ‘scriptcontext.doc = ghdoc’.

Traceback:
line 107, in GetDocumentUserText, “C:\Users*\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\userdata.py”
line 13, in script

__author__ = "Alessandro Innocenti (@inno)"
__version__ = "2022.10.01"

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

sc.doc = Rhino.RhinoDoc.ActiveDoc
a = rs.GetUserText(geo, key)
1 Like

Thanks @Joseph_Oster the idea worked!

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

sc.doc = Rhino.RhinoDoc.ActiveDoc
a = rs.GetDocumentUserText(“test”)

1 Like