Import STL in Rhinodoc

Hi All,

I’m trying to do a STL file import. So far I’have the code below. For other file types this works.
With a runscript command I’m also succeeding, but this doesnt seam ideal for me. The file then gets loaded in the active document.

Any ideas on how i can make the Rhinodoc.import work for STL?

                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.FileName == "")
                    return null;
                RhinoDoc doc = Rhino.RhinoDoc.CreateHeadless(null);
                if(File.Exists(openFileDialog.FileName) == true)
                return doc;

Kind regards Reinder

Hey @r.weenink,

What do you dislike about using RunScript? Is it that the Rhino Geometry is loaded into the active document? What do you want to do with the Geometry you load from the stl?

– cs

What is the problem when you use this for STL files?

@laurent_delrieu had written some STL importer that works very nicely on this post:
//Read a .stl in grasshopper - #9 by kevs3dhub
you’d probably need to rewrite it for rhino instead of grasshopper though, but this would allow you to keep the mesh in teh script without having it in the document.

This tool is now in Nautilus plugin.

Hey CSykes,

I made an assumption here. And maybe I’m to quick. I would like to be able to import STL files in a Rhinodoc while using rhino.compute or Rhino3dmIO library. For me it was/is logical that runscript is not available here.
I’havent tested this so I’m really not sure.

regards Reinder

Hey Menno,

I think this is the same question as CSykes?

regards Reinder


I’m going to take a look.

Regards Reinder

You say it does not work, but no details on what goes wrong. That would help in finding a solution.

Hey Menno,

I tried today again. And now it seems to work. I didn’t alter the code. I’ve done something wrong, maybe clicked the wrong file or something.
I got it to work, thanks for your trouble.

regards Reinder

1 Like