Hi there.
Just wondering if there is a way to export STL files, or get the triangulated data, from OCC geometry with the python api. Works fine from the interface but I can’t find the Python command.
Thanks
Ryan
with the netgen mesh:
ngmesh.Export("test.stl", "STL Format")
best
Hi.
Thank you, but is it possible to do it for the OCC geometry itself, without going through a meshing process, like the “File > Save Geometry - STL file type” interface menu?
Cheers
Ryan
For this there is no interface in netgen, but opencascade can be directly used for stuff like this.
Also the gui cannot do read occ → write stl without meshing step in between
In my experience on Arch linux, with the latest Netgen git, the interface does allow you to export a triangulated STL mesh directly from an OCC file. It will show an “Unknown target format error” window but the STL is still exported. I have attached a STEP file that I can load into Netgen and then just save as an STL.
I think it may work as I am currently working with STEP files that contain only faces, not curves. The Netgen Python API exposes an OCC face triangulation function but when I try and use it I get the error below. Looks like it returns a C construct of triangulated face data that Python cannot understand. I do not know enough about C to know how to follow the advice of the error message. Do you have any simple-to-follow ideas on how I can get Python to understand the triangulated output?
Cheers
Ryan
geo.shape.faces[0].Triangulation()
TypeError: Unregistered type : ngcore::Array<std::array<netgen::Point<3, double>, 3ul>, unsigned long>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “”, line 1, in
geo.shape.faces[0].Triangulation()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
TypeError: Unable to convert function return value to a Python type! The signature was
(self: netgen.libngpy._NgOCC.TopoDS_Shape) → ngcore::Array<std::array<netgen::Point<3, double>, 3ul>, unsigned long>
Did you forget to #include <pybind11/stl.h>
? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.
0.step (197.2 KB)