Newbie Python scripting question (working on a geometry import/ export script for a Grasshopper project)
I’m creating two data trees in the same Python script: one for generic geometry and one for generic data (like integers, floats, strings).
Rhino.Geometry.GeometryBase works for generic geometry types:
myTree = DataTree[Rhino.Geometry.GeometryBase]()
But what data type do I declare for data like the following?
I used the string version of your suggestion: nameTree = DataTree[type(str())]()
where the data looked something like this: name = (5, 2.0, 3.0, 'point')
…and added to the tree like this (converting the above to a string): nameTree.Add(str(name),myPath)
FYI, The export script I made custom names ‘sets’ of objects. The name of every object in each set begins with the same number. When importing the objects I use that number to add those matching objects to the same tree branch. Basically I’m exporting/ importing groups without having to use groups.
The exported object name also contains other useful data about the objects besides what set they belong to that was generated in the Grasshopper file that created them. Bringing that data in through the import process saves me having to regenerate the information in the new Grasshopper file.
@djordje That works even better for my particular use. I was able to structure the data exactly how I wanted. I didn’t know about the .addRange method.
There’s a lot of great information in the links you provided.
Thank-you.