Fillet can not be created using Python but easily via UI

Fillet can not be created using Python but easily via UI

muhaiR2SPM
Participant Participant
450 Views
3 Replies
Message 1 of 4

Fillet can not be created using Python but easily via UI

muhaiR2SPM
Participant
Participant

Hi,

I am having some difficulty to understand why the fillet behavior works differently when using Python script versus using the UI. I have a script that generates a lot of splines (SketchFittedSpline) and lines (SketchLine). Eventually the lines intersect the splines and should be rounded at the at the intersection using the fillet operator.

I dont not face any issues when using the fillet operator between lines and arcs but splines are more difficult to use. To illustrate the problem, I extracted a spline from my model and attached a sample code.

"""This file acts as the main module for this script."""

import traceback
import adsk.core
import adsk.fusion

# import adsk.cam

from adsk.core import DocumentTypes, ObjectCollection, Point3D
from adsk.fusion import Design

# Initialize the global variables for the Application and UserInterface objects.
app = adsk.core.Application.get()
ui = app.userInterface


def run(_context: str):
    """This function is called by Fusion when the script is run."""

    newDocumentName = "Test"
    newDocument = app.documents.add(DocumentTypes.FusionDesignDocumentType)
    newDocument.name = newDocumentName

    design = Design.cast(app.activeProduct)
    rootComp = design.rootComponent
    sketches = rootComp.sketches
    if not newDocument.activate():
        ui.messageBox("Newly created document could not be activated!")
        return

    sketch = sketches.add(rootComp.xYConstructionPlane)
    sketch.name = "Test"

    fitPoints: ObjectCollection = ObjectCollection.create()
    startFitPoint = Point3D.create(0.18336113476039656, 3.522766673615777, 0)
    midFitPoint = Point3D.create(0.21718981258706083, 3.7627597813225755, 0)
    endFitPoint = Point3D.create(0.16831464666888074, 4.051349328459134, 0)

    fitPoints.add(startFitPoint)
    fitPoints.add(midFitPoint)
    fitPoints.add(endFitPoint)

    fittedSpline = sketch.sketchCurves.sketchFittedSplines.add(fitPoints)

    startPoint = Point3D.create(-1.0, 3.18)
    endPoint = Point3D.create(0.45, 3.6)

    line = sketch.sketchCurves.sketchLines.addByTwoPoints(startPoint, endPoint)

    sketch.sketchCurves.sketchArcs.addFillet(line, startPoint, fittedSpline, endFitPoint, 0.4)

    try:
        # Your code goes here.
        ui.messageBox(f'"{app.activeDocument.name}" is the active Document.')
    except:  # pylint:disable=bare-except
        # Write the error message to the TEXT COMMANDS window.
        app.log(f"Failed:\n{traceback.format_exc()}")

 
When adding the fillet via UI, this works out of the box:

muhaiR2SPM_0-1738500628505.png


I am probably missing something when using Python. Any ideas? Are there any other best practices to consider when using the fillet operator with Splines?

0 Likes
451 Views
3 Replies
Replies (3)
Message 2 of 4

BrianEkins
Mentor
Mentor

I can reproduce this and will see that a bug is filed.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 4

muhaiR2SPM
Participant
Participant

@BrianEkinsdo you have any updates on this? Thank you

0 Likes
Message 4 of 4

seth.madore
Community Manager
Community Manager

This should be fixed in the next update going out 🤞


Seth Madore
Customer Advocacy Manager - Manufacturing