Grasshopper

algorithmic modeling for Rhino

Hi all, 

I just started doodling with GH for a couple of days and was trying to write a vb script that would return the userstring name of objects. I fwrote the following lines:

Private Sub RunScript(ByVal oID As Guid, ByRef A As Object) 


Dim obj As New docobjects.ObjRef(oID)    

Dim att As docobjects.ObjectAttributes    

att = obj.Object.attributes    

A = att.GetUserString("key")

 

but what I am missing is an understanding of the keyID string needed for GetUserString().

What should I put here to return the userstring?

 

Thanks

Views: 311

Replies to This Discussion

Hi Pedro,

 

UserStrings are stored as key-value pairs. So there's a Key string and a Value string. You need to use the same key as was used to store the string.

 

I think however you're confused. The object name is not a User String, try

 

<code>att.Name</code>

 

that property provides access to the object name field.

 

--

David Rutten

david@mcneel.com

Seattle, WA

Right.

Thanks a lot for the clarification David :)

Is there a way to directly get the object name without the ID parameter?

 

Cheers

Pedro

Nope, when Grasshopper loads objects from the Rhino document it discards the attributes and only uses the geometry. The Object Name is stored inside the attributes, so you really need to find the object in the Rhino document, get the attributes and read the name.

 

--

David Rutten

david@mcneel.com

Seattle, WA

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service