Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trimming Ellipse

Message 1 of 3
1501 Views, 2 Replies

Trimming Ellipse



apologies for the naive question. I'm just trying to get into fusion scripting and have a hard time to understand how the trim function works. I would like to split an ellipse into two parts to create an arc. From my limited understanding of the documentation I would have expected the following code to create an arc:


        app = adsk.core.Application.get()
        design = app.activeProduct
        rootComp = design.rootComponent
        sketch =  rootComp.sketches.add(rootComp.xYConstructionPlane)

        ellipses = sketch.sketchCurves.sketchEllipses
        ellipse = ellipses.add(adsk.core.Point3D.create(0, 0, 0), 
                               adsk.core.Point3D.create(0, 1, 0), 
                               adsk.core.Point3D.create(2, 0, 0))        
        ellipse.split(adsk.core.Point3D.create(0, 1, 0))
        ellipse.split(adsk.core.Point3D.create(0, -1, 0))
        ellipse.trim(adsk.core.Point3D.create(2, 0, 0))

It would be great if someone could either post a sample code or point me to an example implementing the above?


Thanks a lot,



Message 2 of 3
in reply to: oliver.

Thanks for reporting this.  I did some testing and it seems that Fusion does not support splitting a closed curve.  You can see this in the UI if you draw an arc and then drag the end points so they connect and close the arc.  This could be an arc with a 360 degree sweep but Fusion converts it into a circle.  It doesn't like "open" curves that are physically closed and that's what splitting a circle or an ellipse would do.  However there is a workaround and it's the same technique you would use in the UI.  That is to use either the Trim or Break commands.  These are also available in the API as the trim and breakCurve methods.  With these methods you need to have another curve that defines the split points.  I wrote some code to test these and unfortunately have discovered a problem where they don't work correctly with an ellipse.  The work as expected with a circle but not an ellipse.  I've filed a bug so we can investigate and fix the problem.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3
in reply to: ekinsb

Hi Brian,


Thanks for getting back to me on that topic. I actually started with trying the trim and breakcurve but it lead to a strange behaviour. See a simplified version of the code below.


When you only execute the first trim it works as expected. If you only use the second trim command it works as expected. When combining the two it leads to an unpredictable result: either no segment is being removed or an entire segment chain gets removed. Hope this helps with finding the bug.


Best regard



    circlewidth2 = 2
    circlewidth = 2

    ui = None
        app = adsk.core.Application.get()
        design = app.activeProduct
        rootComp = design.rootComponent
        sketch =  rootComp.sketches.add(rootComp.xYConstructionPlane)

        # draw circle
        sx = 0
        sy = 0

        # Draw 2 ellipses 
        ellipses = sketch.sketchCurves.sketchEllipses

        ellipse1 = ellipses.add(adsk.core.Point3D.create(sx, sy, 0), 
                                adsk.core.Point3D.create(sx+circlewidth2/20, sy, 0), 
                                adsk.core.Point3D.create(sx, sy+circlewidth/20, 0))
        ellipse2 = ellipses.add(adsk.core.Point3D.create(sx+2*circlewidth/10, sy, 0), 
                                adsk.core.Point3D.create(sx+2*circlewidth/10+(circlewidth2/20), sy, 0), 
                                adsk.core.Point3D.create(sx+2*circlewidth/10, sy+(circlewidth/20), 0))

        # Draw a connecting line on the top
        lines = sketch.sketchCurves.sketchLines
        line = lines.addByTwoPoints(adsk.core.Point3D.create(sx, sy+circlewidth/20, 0), adsk.core.Point3D.create(sx+2*circlewidth/10, sy+(circlewidth/20), 0))        

        # Trim the unnecessary part of the ellipses
        ellipse1.trim(adsk.core.Point3D.create(sx+circlewidth2/20, sy-0.001, 0))

        ellipse1.trim(adsk.core.Point3D.create(sx+circlewidth2/20, sy+0.001, 0))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report