Set Meshing Options with Python?

More
4 years 1 week ago #3326 by christopher
first step = perfstepsstart
last step = perfstepsend
in python
and you can set the message level with
ngsolve.ngsglobals.msg_level = 0

Best
Christopher
More
4 years 1 week ago #3327 by mariopa
thx very much!

i will try as soon as possible...
More
3 years 11 months ago #3423 by mariopa
Hello,

I just tried the following python script:

from netgen.occ import *
geo = OCCGeometry("//STI01/STIWA/mail/ParM/ng/projects/parm/abc/Schuettblech.stp")
mesh = geo.GenerateMesh(meshsize.very_coarse, perfstepsstart=MESHCONST_ANALYSE, perfstepsend=MESHCONST_OPTSURFACE, curvaturesafety=5)
Draw(Mesh(mesh))
mesh.Export("//.................stl", 'STL Format')

does not work :-( --> 'MESHCONST_ANALYSE' is not defined

what I did wrong?

(should) load python file '\\STI01\STIWA\mail\ParM\ng\projects\parm\abc\tmp.py'
Traceback (most recent call last):
File "<string>", line 2, in <module>
FileNotFoundError: [WinError 3] Das System kann den angegebenen Pfad nicht finden: 'C:\\STI01\\STIWA\\mail\\ParM\ng\\projects'
Number of colours in STEP File: 1
Colour [1] = LIGHTBLUE3 : (0.654902,0.760784,0.788235)
Highest entry in topology hierarchy:
1 solid(s)
Traceback (most recent call last):
File "<string>", line 3, in <module>
NameError: name 'MESHCONST_ANALYSE' is not defined
Finished executing \\....................py
Preparing visualization (deflection = 0.01) ... done
More
3 years 11 months ago #3424 by cwinters
Hi,

having a look at the code, I found a python enum "MeshingStep":
Code:
py::enum_<MESHING_STEP>(m,"MeshingStep") .value("ANALYSE", MESHCONST_ANALYSE) .value("MESHEDGES", MESHCONST_MESHEDGES) .value("MESHSURFACE", MESHCONST_OPTSURFACE) .value("MESHVOLUME", MESHCONST_OPTVOLUME) ;

So just use
Code:
from netgen.meshing import MeshingStep mesh = geo.GenerateMesh(meshsize.very_coarse, perfstepsstart=MeshingStep.ANALYSE, perfstepsend=MeshingStep.MESHSURFACE, curvaturesafety=5)
to generate the mesh.

Best,
Christoph
More
3 years 11 months ago #3425 by mariopa
thanks very much!

and is there a enum for MESHCONST_OPTSURFACE and MESHCONST_OPTVOLUME too?

regards, mario
More
3 years 11 months ago #3426 by cwinters
The enum "MeshingStep" contains all these options (ANALYSE, MESHEDGES, MESHSURFACE, MESHVOLUME). I copied the export to python in my last post.
Time to create page: 0.106 seconds