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.
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.
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);
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);
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.
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.
Getting the following error when trying this code in Revit 2023: "the provided options are not valid"
Getting the following error when trying this code in Revit 2023: "the provided options are not valid"
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 🙂
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 🙂
Can't find what you're looking for? Ask the community or share your knowledge.