netgen icon indicating copy to clipboard operation
netgen copied to clipboard

modification of occ sub allowing to get modified faces and prescribe maxh on them

Open QubaB opened this issue 4 weeks ago • 0 comments

get_cut_faces() can be used after substraction of objects to receive changed faces which correspond to cutting object

get_all_cut_faces() can be used after substraction of objects to receive all changed faces

Sample code:

def polygon_from_coords(coords):
    """
    Creates a polygon face, coordinates must be put in counter-clockwise order
    """
    wp = WorkPlane().MoveTo(*coords[0])
    for p in coords[1:]:
        wp.LineTo(*p)
    return wp.Close().Face()

# create geometry, an arbitrary shape
shape = polygon_from_coords([[0.0,1.0],[0.8,0.25],[1.0,0.25],[1.0,1.0]])
shape.faces.name = "mat"
shape3D = shape.Revolve(Axis((0, 0, 0), X), 360) # originally cyllindrically symmetrical
hole = Cylinder(Pnt(0.4,0.1,0.0),X,0.4,0.7) # hole for subtraction, slightly longer in order to cut all the way through the shape

whole = shape3D-hole    # substract objects
Draw(whole)

print(f"Number of cut faces {len(whole.get_cut_faces())}")  # get number of cut faces
for cutf in whole.get_cut_faces():
    cutf.maxh=0.05   # prescribe maxh on them
mesh = whole.GenerateMesh()
Draw(mesh)

QubaB avatar Dec 13 '25 16:12 QubaB