Working with imported geometry

Hi,
I’m new to this forum and also learning NGSolve.

I had a very basic set of questions:

  1. In examples that I have seen, one can create geometry by declaring an object and then add items to it. This object then can be referred to for meshing, etc. My query is if I import geometry from an external STEP file, with what name this geometry is available for further operations.

  2. Similarly when I generate a mesh using the GUI, with what name I can access the mesh when writing python commands for further operations.

Please let me know if my query is clear enough. I tried to understand the above steps but could not find a resolution on my own. Many thanks for your help…

I’ve attached the sample geometry STEP file.

https://ngsolve.org/media/kunena/attachments/969/191_SD_Flat.zip

Attachment: 191_SD_Flat.zip

I tried below commands and received an error:
####################
import netgen.gui
%gui tk
from ngsolve.solve import Draw, Redraw # just for visualization

from netgen import NgOCC
geo = NgOCC.LoadOCCGeometry(“191_SD_Flat.stp”)

geo.Draw()
Redraw()

AttributeError Traceback (most recent call last)
in ()
6 geo = NgOCC.LoadOCCGeometry(“191_SD_Flat.stp”)
7
----> 8 geo.Draw()
9 Redraw()

AttributeError: ‘netgen.libngpy._NgOCC.OCCGeometry’ object has no attribute ‘Draw’
###################

What could be going wrong? Thanks.

Hi,

To generate a mesh from your geometry and see the mesh and geometry in Netgen, you can do something like this:

[code]import netgen.gui
%gui tk

from netgen import NgOCC
geo = NgOCC.LoadOCCGeometry(“191_SD_Flat.stp”)
msh = geo.GenerateMesh()

[/code]
It may take a couple minutes to generate the mesh. Once the mesh is complete, you can select Geometry or Mesh in the Netgen GUI to see the result. You can also control the maximum element dimension by
msg = geo.GenerateMesh(maxh=0.5)

Hope that helps!

Best,
Dow

Hi Dow,
Thanks. This works.
Regards…

Hi,

the Draw function is just available for a CSGeometry an not for a OCCGeometry by now.

Best,
Christoph

Thanks Christoph. That clears the doubt…
Regards,
RD