Disable auto projected geometry when using the API?

Disable auto projected geometry when using the API?

tiktuk
Advocate Advocate
355 Views
2 Replies
Message 1 of 3

Disable auto projected geometry when using the API?

tiktuk
Advocate
Advocate

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?

 

Screenshot 2023-03-11 at 16.04.39.png

0 Likes
Accepted solutions (1)
356 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @tiktuk .

 

Try using the Sketches.addWithoutEdges method when creating a sketch.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1DC465D6-BC5B-4424-82FC-64CE59675C92 

 

There is no need to change the preferences.

Message 3 of 3

tiktuk
Advocate
Advocate
Thanks @kandennti, just what I was looking for 🙂 !
0 Likes