Read .3dm file in grasshopper

Hi there.

I use to open 3dm file into grasshopper with the read 3dm file tool in an old “human” version :
this one :
3dm


(I did open an old file on a friend computer who is not up to date to take thoose pics)

but this tool seems to be no longer available in the newest human version.
I tried to “import 3DM” tool but it seems not to import attributes (and I need them) :

any idea any VB / python ready to use solution ? because I did find some code parts on google but I just absolutely don’t know how to make them work…

thanks for your help !

here is an example that shows how to import objects from a 3dm file by layer and getting their attributes / geometry

import3dmWithAttributes.gh (14.6 KB)

which plugin are you using to read the attributes?

1 Like

thanks, it seems great, gonna try it soon.

i generally used elefront for attributes, and sometimes human.
thanx

Hi Lando,

I just found your Python snippets and found them very interesting. I wondered how to retrieve the text content of a 3dm-file as a list. I am currently trying to read closed 3dm files and achieved to read closed polylines to measure their area and save them to an excel sheet. Now, I am trying to connect text objects with the measurements in excel but am failing in the attempt to read the content of the text objects from a sries of closed 3dm files. I have to say that my Python knowledge is very, very basic. Could you give me a hint on how to retrieve the information?

Kind regards

Ante

Hello,
Try attached example
read3dm.gh (3.7 KB)

1 Like

Hi djordje,

you are definetely a master. Thank you very much.

I´ve been trying to figure out the whole of last evening and into the night and another few hours today skipping through the RhinoCommon API only to get stuck with File3dmStringTable Methods. I think I would have spent even Sunday to no avail. You saved my day!

Did I get it right? I have to narrow down the instantiated Objects.Enumerator via file3dmObj to then check for TextEntities before appending. I´d never have gotten to that point. Where can I find these descriptions in RhinoCommon? This is a riddle wrapped up in an enigma to me. How did you learn this?

Kind regards and many, many thanks

Ante

Something like that. Everything is in online RhinoCommon documentation. Essentially File3dm class follows similar principles to Rhino’s active document.

File3dm class has Tables where objects of certain type are stored: Layers, Materials, Hatches, and also geometry Objects, which is what you are looking for.

In this case, we need the geometry Objects table.
So we have to iterate through all of them and check if they are of the instance we are looking for (text in this case).

Forget about the enumerator. It is a C# like syntax.

We can use:

for file3dmObj in file3dm.Objects:
    obj = file3dmObj.Geometry

instead.

1 Like

ah ok… it´s getting clearer. still the steps from the variable “file3dm” to “file3dm.objects” to “file3dmObj” to “file3dmObj.Geometry” is everything else but obvious to me… never found this kind of structural breakdown on RhinoCommon which is essential to my understanding of tables. On the other hand I am guessing this is something that probably relates more to python coding logics than rhinocommon. anyway, it´s good to have someone giving a glimpse to move forward from. have a nice weekend.

file3dm is similar to RhinoDoc.
In RhinoDoc you have ‘Objects’ table.
If you iterate through objects in that table you will find instances derived from RhinoObject, which have properties like ‘Id’, ‘Geometry’, ‘Name’…
The same thing is with File3dm class: we iterated through its ‘Objects’ table where File3dmObject instances reside, and retrieved their ‘Geometry’ property.

1 Like

Thank you for your explanations. As I mentioned, the only thing that is not obvious is the way how the access paths may be addressed properly. Besides that, RhinoCommon is pretty comprehensible as are your explanations. Have a sunny Sunday.

p.s. here´s the result of my endeavours 210220 Flächenauswertung.gh (31 KB)

hi Lando Schumpich !
Have you ever tried to read a dimensionStyle of annotationBase?
I try I tried, but the result was wrong.
It just returns the default value.
Do you have any good suggestions.
Thanks a lot!

                            AnnotationBase annotationBase = rhinoObject.Geometry as AnnotationBase;
                            DimensionStyle dimensionStyle = annotationBase.DimensionStyle;
                            DimensionStyle dimensionStyle2 = annotationBase.ParentDimensionStyle;


                            if (dimensionStyle==null)
                            {
                                RhinoApp.WriteLine("dimensionStyle==null");
                            }
                            else
                            {
                                RhinoApp.WriteLine(dimensionStyle.Name);//default value
                            }


                            if (dimensionStyle2 == null)
                            {
                                RhinoApp.WriteLine("dimensionStyle2 == null");//null
                            }
                            else
                            {
                                RhinoApp.WriteLine(dimensionStyle2.Name);
                            }