Hello,
I’m looking for a way to transform STEP Files to lowpoly 3DFiles (f.e. STL). With netgen’s GUI I received excellent results. Now I’m working on a way to do that via command line. I found an solution to transform STEPs to the Netgen neutral format with python. As far as good, I want to test around with the available meshing paramters, but I have problems to examine the neutral format. Where is it loadable? Or my generated file is corrupt, I dont know.
Is there are solution for exporting STL Files?
Here my solution and many thanks for help!!
→ convert.py
FREECADPATH = ‘/usr/share/netgen’
import sys
sys.path.append(FREECADPATH)
import netgen.meshing as meshing
from netgen.meshing import MeshingParameters
from netgen.csg import *
from netgen.NgOCC import *
geo = LoadOCCGeometry(‘Part_003.step’)
m1 = geo.GenerateMesh(maxh=1000, perfstepsend=meshing.MeshingStep.MESHSURFACE)
import exportNeutral
exportNeutral.Export (m1, “shaft.mesh”)
→ exportNeutral.py
import sys
def Export (mesh, filename):
“”" export Netgen mesh to neutral format “”"
print ("export mesh in neutral format to file = ", filename)
f = open (filename, 'w')
points = mesh.Points()
print (len(points), file=f)
for p in points:
print (p.p[0], p.p[1], p.p[2], file=f)
volels = mesh.Elements3D();
print (len(volels), file=f)
for el in volels:
print (el.index, end=" ", file=f)
for p in el.points:
print (p.nr, end=" ", file=f)
print(file=f)