CREATE STL FILE

CREATE STL FILE

tselvakkani23
Observer Observer
934 Views
4 Replies
Message 1 of 5

CREATE STL FILE

tselvakkani23
Observer
Observer

I need to export the revit families file to STL file(as like as Export manual process) using C#.Net API code. Is it possible?

If possible, please provide the sample code for Revit 2021.

0 Likes
935 Views
4 Replies
Replies (4)
Message 2 of 5

richard.schmitt.sg
Contributor
Contributor

pretty simple take your document and tell it to export an STL (only available for 2021 and onward)

revit api docs Document.Export 

 

STLExportOptions options = new STLExportOptions();
doc.Export(folderPath, fileName, options);
0 Likes
Message 3 of 5

LyleHardin
Advisor
Advisor

Just a heads up. Not much help from my end, but I thought I'd let you know that depending on what you're exporting and what you plan on doing with it, it may or may not work. For instance, exporting a building to be 3D printed doesn't work well at all on the 3D printer side of things. At least it didn't for me when I used the STL Export command from Revit. Way too much detail and data. And it wasn't watertight. I ended up having to remodel everything in AutoCAD 3D Solids (which only took a few hours) then export that to STL for it to work with the 3D printers we sere using.

 

0 Likes
Message 4 of 5

chrisP6TSM
Explorer
Explorer

Getting the following error when trying this code in Revit 2023: "the provided options are not valid"

0 Likes
Message 5 of 5

Mohamed_Arshad
Advisor
Advisor

HI @chrisP6TSM 

You have to give the ViewId in the STLExportOptions. Means Defining View to Export.

Kindly refer the below code for additional reference.And use the given options in the STLExportOptions to export STL with more accuracy.

 

            //Export Options
            STLExportOptions opt = new STLExportOptions();
            opt.ViewId = doc.ActiveView.Id;

            //folder--> Give only the Folder path
            doc.Export(folder, "Demo.stl", opt);

 

Hope this will Helps 🙂

 


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes