Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Having issues with Split & BreakCurve on SketchFittedSpline

chris.monachanZWSCF
Enthusiast

Having issues with Split & BreakCurve on SketchFittedSpline

chris.monachanZWSCF
Enthusiast
Enthusiast

I've been running into issues with using either Split or BreakCurve on a fitted spline. I have a very simple sketch spline with 2 control points (start and finish) . I draw a straight line across it and ask fusion for the intersections. It provides me with a point where the straight line crosses the spline.

 

Example of issueExample of issue

 

When I call Split or BreakCurve on the spline at that point, sometimes it works, sometimes it doesn't. In the supplied image, you can see I have four intersections points. Sometimes they all work, sometimes only three. If I move the position of the straight lines, it sometimes makes things work. 

 

I've spent ages trying to debug this, and I'm starting to conclude that Split/BreakCurve on a spline doesn't work properly, can anyone confirm?

 

Sometimes BreakCurve returns a single curve which is the original curve I'm trying to break. According to the documentation it should either return the broken two curves, or an empty container. Sometimes it returns that, sometimes it returns a nullptr. I see internal exceptions being thrown from fusion but I don't know what they are.

 

Things to add are that fusion sees the interception points as it gives them to me when I call that function and it also automatically generates a profile of the bit I'm interested in automatically using the geometry. And it works fine if I hit split in the UI at the interception points. Also this is all in parametric modelling.

 

If it's not an obvious bug that people know about, I can spend some time putting together a repo if it helps. 

0 Likes
Reply
438 Views
3 Replies
Replies (3)

kandennti
Mentor
Mentor

Hi @chris.monachanZWSCF .

 

I created a test code that looks like this.

# Fusion360API Python script
import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        skt :adsk.fusion.Sketch = root.sketches[0]
        line :adsk.fusion.SketchLine = skt.sketchCurves.sketchLines[0]
        crv :adsk.fusion.SketchFittedSpline = skt.sketchCurves.sketchFittedSplines[0]

        objs :adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
        objs.add(crv)
        _, _, intersectionPoints = line.intersections(objs)

        execSplitCurve(line, intersectionPoints)
        execSplitCurve(crv, intersectionPoints)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def execSplitCurve(
    crv :adsk.fusion.SketchEntity,
    pnts :list):

    crvs = [crv]
    for pnt in pnts:
        for crv in crvs:
            res = crv.split(pnt, True)
            # res = crv.breakCurve(pnt, True)
            if res.count > 1:
                crvs = res
                break

 

In the sketch, I created the following line and curve and ran the script I just wrote.

1.png

The split method worked fine.

 

 

Next, to test the breakCurve method, I reverted the curve to its pre-split state, modified the code and ran it, but it gave an error.

・・・
    crvs = [crv]
    for pnt in pnts:
        for crv in crvs:
            # res = crv.split(pnt, True)
            res = crv.breakCurve(pnt, True)
            if res.count > 1:
                crvs = res
                break

 

I changed the curve in the sketch to the following state and ran it again.

2.png

 

When I set the intersection point to one, I was able to split the line, but the curve gave me an error.

(I think this has something to do with the order in which the processing is done.)

 

I changed the curve of the sketch again to the following state and ran it again.

3.png

When the endpoint of the curve was on the straight line, the error occurred.

 

 

My guess is that the breakCurve method only works when there is only one complete intersection.

0 Likes

BrianEkins
Mentor
Mentor

I also did a quick test of split and in my test, it worked as expected.  Since you indicated the failure is inconsistent, it would be best if you can post an f3d that can be used to demonstrate the problem.  Typically, if a problem can be reproduced it can be fixed.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes

chris.monachanZWSCF
Enthusiast
Enthusiast

Excellent thanks, that's good to know.

 

I'll try and put together a repro. It's a very complex project so pulling this out in isolation with the failing code may take me a little bit of time.

0 Likes