How to create cylindrical cavities inside a rectangular block array?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
This is the first time I post here, so I apologize if I am not so clear.
I have a running code that creates a rectangular block. However, I also need to create a circular cross-section hole inside this rectangular block. Is there any way to create it by knowing its location? It will be at the center of the rectangular block, but not through holes (their height is smaller than the rectangle). Here is the running code to create a rectangle extrusion and I would like to add a hole, as well. I also attached the original python file to the post.
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
design = app.activeProduct
design.designType = adsk.fusion.DesignTypes.ParametricDesignType
# Get the root component of the active design.
rootComp = design.rootComponent
# Create a base feature
baseFeats = rootComp.features.baseFeatures
baseFeat = baseFeats.add()
baseFeat.startEdit()
# Create a new sketch on the xy plane.
sketches = rootComp.sketches;
xyPlane = rootComp.xYConstructionPlane
sketch = sketches.add(xyPlane)
# Draw two connected lines.
lines = sketch.sketchCurves.sketchLines;
# Draw a rectangle by a center point.
recLines = lines.addCenterPointRectangle(adsk.core.Point3D.create(5,6, 0), adsk.core.Point3D.create(2, 1, 0))
# Get the profile defined by the circle.
prof = sketch.profiles.item(0)
# Create an extrusion input to be able to define the input needed for an extrusion
# while specifying the profile and that a new component is to be created
extrudes = rootComp.features.extrudeFeatures
extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
# Define that the extent is a distance extent of 5 cm.
distance = adsk.core.ValueInput.createByReal(5)
extInput.setDistanceExtent(False, distance)
extInput.baseFeature = baseFeat
# Create the extrusion.
ext = extrudes.add(extInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))