Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to make a simple box on a face, using the API.
I want the box to be slightly larger than body's bounding box so I'm extruding a sketch based on the bounding box coordinates.
The problem is that the geometry of the face seems to be auto projected into the sketch so only the profile outside the sketch is extruded. I found the settings Auto project edges on reference and Auto project geometry on active sketch planes and made sure both were turned off. This had the expected effect when creating sketches manually but didn't have any effect on the script.
Relevant code:
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
# Capture the initial position on the timeline for when grouping our features.
timelineInitialPosition = design.timeline.markerPosition
# Get the skeleton body via our face.
body = faces[0].body
# We create the dividers by intersecting the skeleton body with large bodies the thickness of the dividers.
# Get the bounding box of the body.
bbox: adsk.core.BoundingBox3D = body.boundingBox
futil.log(f'Bounding Box: {bbox.minPoint.x} {bbox.minPoint.y} {bbox.minPoint.z} {bbox.maxPoint.x} {bbox.maxPoint.y} {bbox.maxPoint.z}')
# intersectorBody = create_box(width, height, depth)
# Get the root component of the active design.
rootComp = design.rootComponent
# Define two points
centerPoint = adsk.core.Point3D.create(5, 5, 0)
cornerPoint = adsk.core.Point3D.create(25, 25, 0)
# We make it slightly bigger than the bounding box of the body so we're sure there's overlap.
margin = 10
minPointForIntersector = adsk.core.Point3D.create(bbox.minPoint.x - margin, bbox.minPoint.y - margin, 0)
maxPointForIntersector = adsk.core.Point3D.create(bbox.maxPoint.x + margin, bbox.maxPoint.y + margin, 0)
# Create sketch
sketches = rootComp.sketches
sketch: adsk.fusion.Sketch = sketches.add(faces[0])
# Create the rectangle using the points
rectangles = sketch.sketchCurves.sketchLines
rectangle = rectangles.addTwoPointRectangle(minPointForIntersector, maxPointForIntersector)
# Get the profile defined by the circle.
prof = sketch.profiles.item(1)
# Create an extrusion input
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)
# Create the extrusion.
ext = extrudes.add(extInput)
So how to avoid this?
Solved! Go to Solution.