How access UserDictionary in Python?

Glad to see that you already found the answer :slight_smile:

Anyway here is a very simple test script

import Rhino
import rhinoscriptsyntax as rs

def main():
  gob = Rhino.Input.Custom.GetObject()
  gob.SetCommandPrompt( 'Object ?' )
  gob.Get()
  key = rs.GetString( 'Key ?' )
  val = rs.GetString( 'Value [Enter to read] ?' )
  rob = gob.Object( 0 ).Object()
  if val:
    rob.Attributes.SetUserString( key, val )
    print( 'Written value ' + val )
  else:
    val = rob.Attributes.GetUserString( key )
    print( 'Read value ' + val )

main()

I agree that what is missing AFAIK is a general explanation of what does what.

References that I know of are the samples here:


… and the rhinoscriptsyntax source copied on our PCs along with Rhino (very useful IMO)

If you allow a few quick (and maybe confused) words from a non-expert …
Geometry is just that: theoretical geometrical objects
Object and ObjRef refer to what sits in Rhino’s data base, representing the geometrical objects we see on the screen
An Object contains a Geometry instance, but with RhinoCommon we can also work with Geometry instances (unlike rhinoscripsyntax, that can only reference Rhino Objects )

HTH

EDIT:
Rhino’s data base that I mentioned earlier is here:
http://developer.rhino3d.com/api/RhinoCommonWin/html/N_Rhino_DocObjects_Tables.htm
I think these tables, mostly object tables, layer tables, etc are a good start point to understand how Rhino works … for scripting purposes, I mean

1 Like