Grasshopper

algorithmic modeling for Rhino

Hi!

In order to solve the problem raisen in this discussion, I am trying to transform a UserText created by the geometry cache component into an Object name on python.

I found rs.GetUserText and rs.ObjectName but I think I am not using the key value argument in the GetUserText function right. 

Here is my code so far (iron python on rhino 5):

#import rhinoscript librarie
import rhinoscriptsyntax as rs

#get the objects from rhino
arrObj = rs.GetObjects("Select Objects to rename")

for Obj in arrObj :
.....UserTxt = rs.GetUserText(Obj, key="Cache(INT_PT)", attached_to_geometry=True)
.....print (UserTxt)

.....rs.ObjectName (Obj, name = UserTxt)

I tried with empty key, it returns  "[]" (empty array?), the key "Cache(INT_PT)" (from the name set in the geometry cache component) returns empty string.

I also attached my gh test.

Any clue on the use of GetUserText ?

Thanks !

Views: 1009

Attachments:

Replies to This Discussion

Some update :

I managed to find the key automatically (had to set the "attached_to_geometry" to false, not sure of what it implies). But it comes as a list, not a string, I tried unsuccessfully to transform it but am stuck at this point...

#import rhinoscript librarie
import rhinoscriptsyntax as rs

#get the objects from rhino
arrObj = rs.GetObjects("Select Objects to rename")


if arrObj :
.....for Obj in arrObj :
..........UserKey = rs.GetUserText(Obj, attached_to_geometry=False)
..........UserTxt = rs.GetUserText(Obj, key = UserKey, attached_to_geometry=False)
..........print (UserTxt)
..........
..........rs.ObjectName (Obj, name = UserTxt)

edit : GOT IT!!

#import rhinoscript librarie
import rhinoscriptsyntax as rs

#get the objects from rhino
arrObj = rs.GetObjects("Select Objects to rename")


if arrObj :
.....for Obj in arrObj :
..........UserKey = rs.GetUserText(Obj, attached_to_geometry=False)
..........UserTxt = rs.GetUserText(Obj, key = "".join(UserKey),attached_to_geometry=False)
..........print (UserTxt)
..........
..........rs.ObjectName (Obj, name = UserTxt)

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service