Hey Guys,

I’m currently trying mesh a geometry, composed of two cylinders. I just can’t seem to find my error and I would be very grateful for help

```
from ngsolve import *
from netgen.csg import *
from netgen.occ import *
import pyngcore as ngcore
from netgen.meshing import *
# Define radius and height of 1st clinder
radius = 1
height = 1.0
# 2nd cylinder
radius2 = 0.1
height2 = 0.5
# Define start point and direction of 1st cylinder
start_point = gp_Pnt(0, 0, 0)
direction = gp_Dir(0, 0, 1)
# 2nd cylinder
start_point2 = gp_Pnt(radius - radius / 10, 0, 0.5)
direction2 = gp_Dir(1, 0, 0)
# Generate cylinders
cylinder1 = Cylinder(gp_Ax2(start_point, direction), radius, height)
cylinder2 = Cylinder(gp_Ax2(start_point2, direction2), radius2, height2)
# Combine Cylinders
cylinder_combined = cylinder1 + cylinder2
geo = OCCGeometry(cylinder_combined)
# Generate mesh
ngcore.SetNumThreads(24)
with ngcore.TaskManager():
mesh = Mesh(geo.GenerateMesh(maxh=0.5))
```

The occuring Error is the following one:

```
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. netgen.libngpy._meshing.Mesh(dim: int = 3, comm: pyngcore.pyngcore.MPI_Comm = <pyngcore.pyngcore.MPI_Comm object at 0x000002B5733647B0>)
Invoked with: <netgen.libngpy._meshing.Mesh object at 0x000002B564E440B0>
```

It occurs in line 33, where the mesh schould be generated.

Thank you very much for your help!

Have a nice day!

netgen.meshing has a Mesh class and ngsolve has a Mesh class.

What you want is to wrap the netgen mesh created by geo.GenerateMesh into a NGSolve Mesh object. But with the line

```
from netgen.meshing import *
```

you set the netgen mesh class to be visible.

Just move the import ngsolve statement below your netgen.meshing one.

Thank you for your answer!

The code is running through now! But unfortunately it still doesn’t seem to create a mesh.

What do you mean with “doesnt create mesh”?

Do you draw it?

Sorry for the delayed answer, I was sick.

Anyway, yes, I draw the mesh but it seems like there is none created. The netgen window only shows the geometry and nothing when I pick the option “mesh” in the dropdown menu. Only when I click on “Generate Mesh” in the netgen window, it will show a mesh.

I edited the code a little but here is the whole sequence:

```
from netgen.csg import *
from netgen.occ import *
import pyngcore as ngcore
from netgen.meshing import *
from ngsolve import *
import numpy as np
import math
### Bearing ------------------------------------------------------
# Diameter [m]
D = 2
r = D/2
# Width [m]
b = 1.0
### Small cylinders ----------------------------------------------
# Diameter [m]
d_s = 0.2
r_s = d_s/2
# Depth [m]
h = 0.1
# Start of holes measured from x-Axis [°]
phi_start = -90
# End of holes measured from x-Axis [°]
phi_end = 90
# Angle between holes [°]
phi_distance = 20
### Code ---------------------------------------------------------
# Define start point and direction of 1st cylinder
start_point = gp_Pnt(0, 0, 0)
direction = gp_Dir(0, 0, 1)
# Get angle array for further computations
phi_start = phi_start * math.pi / 180
phi_end = phi_end * math.pi / 180
phi_distance = phi_distance * math.pi / 180
phi = np.arange(phi_start, phi_end + phi_distance, phi_distance)
# Position of small cylinders
start_point_s = []
direction_s = []
for phi in phi:
start_point_s.append(gp_Pnt(0.9 * r * math.cos(phi), 0.9 * r * math.sin(phi), b/2))
direction_s.append(gp_Dir(math.cos(phi), math.sin(phi), 0))
# Create cylinders
cylinder1 = Cylinder(gp_Ax2(start_point, direction), r, b)
cylinder_combined = cylinder1
cylinder_s = []
for i in range(len(start_point_s)):
cylinder_s.append(Cylinder(gp_Ax2(start_point_s[i], direction_s[i]), r_s, h + 0.1 * r))
cylinder_combined = cylinder_combined + cylinder_s[i]
geo = OCCGeometry(cylinder_combined)
Draw(geo)
# generate mesh
ngcore.SetNumThreads(24)
with ngcore.TaskManager():
mesh = Mesh(geo.GenerateMesh(maxh=0.5))
Draw(mesh)
```

Thank you for your help!

when executing this code I get a mesh and it looks fine: