In the Python hwx library, the “extrude” function is explained as in the image, but “parts” does not work correctly. For example, I wanted to do a Substract operation with the following line of code. In the code, I specified “parts=substractPart” in the function. Although Part(1) appears in the “Merge with” section of the extrude tool, it substracts all parts because the “All parts” option is still active in this section.
Code:
from hwx import inspire
# Extrude As Solid
model = inspire.newModel()
s = inspire.core.Sketch()
s.addRectangle2Vertex((0, 0), (2, 2))
s.realize()
sketch_part = model.getAllChildren('SketchPart')[0]inspire.geometry.extrude(sketch_part.getFeatures(type=inspire.FeatureArea), "SINGLE", "NEW_PART", extrudeTo1=0.1)
s = inspire.core.Sketch()
s.addCircleCenterRadius((1, 1), 0.3)
s.realize()
sketch_part = model.getAllChildren('SketchPart')[1]
sketch_part.position
p = model.parts[0]
faces = p.getFeatures('FeaturePlanar')
inspire.geometry.extrude(sketch_part.getFeatures(type=inspire.FeatureArea), "SINGLE", "SUBTRACT", extrudeTo1=faces[4])
# Extrude As Sheet
s = inspire.core.Sketch()
s.addRectangle2Vertex((0, 0), (2, 2))
s.realize()sketch_part = model.getAllChildren('SketchPart')[0]inspire.geometry.extrude(sketch_part.getFeatures(type=inspire.FeatureArea), "SYMMETRY", "NEW_PART", extrudeTo1=0.1, angle1=45, extrudeAsSolid=False, reference=(0, 0, 1), extrusionEndCaps="BOTH")
#Problem here !!!!!!!
cutSketch = model.getAllChildren('SketchPart')[-1]
substractPart = model.parts[-1]
inspire.geometry.extrude(cutSketch.getFeatures(type=inspire.FeatureArea),"SYMMETRY","SUBTRACT",extrudeTo1=0.2,parts=[substractPart])
inspire.orientView(direction="isometric")
Tool view:
Function: