How to get keys and values of "attribute user text" from a remote 3dm file in GH?

I’d like to access the keys and values of the attribute user text for each of several geometries on different layers as shown below.

May I ask what RhinoCommon class/property/method I should use? Thanks.


Image 37

get_user_text_attrib.gh (6.7 KB)
b02.3dm (146.2 KB)

import Rhino

def getKeysAndValues():
    filter = Rhino.DocObjects.ObjectType.AnyObject
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success: 
        return
    keys  = objref.Object().Attributes.GetUserStrings()
    for key in keys:
        
        value = objref.Object().Attributes.GetUserString(key)
        print key +":"+ value

getKeysAndValues()
2 Likes