Rhino inside Python

Update
I fixed it using the GetUserText method from RhinoScriptSyntax.
Which makes me wonder :thinking:, could this RhinoScript module just not be part of RhinoInside python package? It seems like a large collection of helper functions that would really benefit python developers.

Hi all :vulcan_salute:

I am trying to collect user data from objects by importing a .3dm file in a headless doc, but with no luck thus far. There don’t seem to be any items in the archivable dictionaries :face_with_raised_eyebrow: See sample code and file below.

In this post, it is recommended to use rhinoscriptsyntax.

  • Am I doing something wrong?
  • Can rhinoscriptsyntax be used in combination with Rhino inside Python?

Thanks :raised_hands:

import rhinoinside
rhinoinside.load()
import Rhino
import pathlib

path = pathlib.Path(__file__).parent.absolute()

input_file = f"{path}\Line-With-User-Data.3dm"

rhino_doc = Rhino.RhinoDoc.CreateHeadless(None) 
rhino_doc.Import(input_file)  
rhino_objs = rhino_doc.Objects

for rhino_obj in rhino_objs:
    # get data by user dictionary
    archivable_dictionary = rhino_obj.Attributes.UserDictionary 
    archivable_dictionary_count = archivable_dictionary.Count #returns 0

    # get data by user data
    user_data_list = rhino_obj.Attributes.UserData 
    user_data_list_count = user_data_list.Count #returns 2
    archivable_dictionary2 = user_data_list.get_Item(0).Dictionary #returns archivable dictionary
    archivable_dictionary2_count = archivable_dictionary2.Count #returns 0

rhino_doc.Dispose()

Line-With-User-Data.3dm (53.1 KB)