intersectWithCurve not returning the right count (it's missing intersections)

intersectWithCurve not returning the right count (it's missing intersections)

corbin2
Enthusiast Enthusiast
807 Views
9 Replies
Message 1 of 10

intersectWithCurve not returning the right count (it's missing intersections)

corbin2
Enthusiast
Enthusiast

Hi!

 

I'm having trouble using Line3D.intersectWithCurve(). It seems to miss intersections at certain points.

 

1. Consider this basic sketch; it has one curve (a SketchControlPointSpline -- created in Illustrator) and point Point3D, near the top left of the curve (shown blue, selected). 

 

Screenshot 2026-01-13 at 12.11.24 PM.png

2. Some basic code creates a Line3D starting at the point and going to the right; it should intersect this curve two times, but the result is only one. Code (full example attached):

 

        design: Design = app.activeProduct

        sketch = design.rootComponent.sketches[0]
        point = sketch.sketchPoints[3].geometry # hardcoded to the right one
        print(point.x, point.y)
        endPoint = point.copy()
        endPoint.x += 100000
        line = Line3D.create(point, endPoint)
        curve = sketch.sketchCurves[0].geometry
        intersects = line.intersectWithCurve(curve)
        hitCount = intersects.count
        # ui.messageBox(f'hitCount should be 1 but is: {hitCount}')
        print(hitCount)

 

I attached the .f3d file and the basic script to reproduce it. It is hardcoded and extracted from my more complex plugin.

 

Moving the point around seems to give the right result when it isn't at the apex/top of the curve.  If yo move it in the middle of the apex (convex side), it will show 0 hits.

 

I'm guessing this is some rounding error or a bug...I'm open to suggestions on how to solve line intersections with arbitrary curves!

 

Corbin

0 Likes
Accepted solutions (1)
808 Views
9 Replies
Replies (9)
Message 2 of 10

BrianEkins
Mentor
Mentor

I can reproduce this, and it appears to be a bug in the intersectWithCurve method. A bug has been logged. Out of curiosity, where did the curve come from? I'm guessing it was imported somehow.

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

corbin2
Enthusiast
Enthusiast

Thanks Brian! I mentioned it briefly, but the curve was created in Adobe Illustrator.

 

I'm working on a work around by implementing my own intersectWithCurve, but I'm hitting the same issue. I haven't debugged it much yet.

 

Corbin

0 Likes
Message 4 of 10

MichaelT_123
Advisor
Advisor

Hi Mr Corbin2,

 

Consider checking:

(returnValue, intersectingCurves, intersectionPoints) = sketchControlPointSpline_var.intersections(sketchCurves)
returnValue = plane_var.intersectWithCurve(curve)

and also:

line = Line2D.create(point, endPoint)

Regards

MichaelT 

MichaelT
0 Likes
Message 5 of 10

corbin2
Enthusiast
Enthusiast

@MichaelT_123 wrote:

Hi Mr Corbin2,

 

Consider checking:

(returnValue, intersectingCurves, intersectionPoints) = sketchControlPointSpline_var.intersections(sketchCurves)
returnValue = plane_var.intersectWithCurve(curve)

and also:..


Hi MichaelT,

I should have mentioned that I also did try SketchCurve.intersections(..) and it fails too. I'm guessing that the algorithm subdivides the curve and compares distances, but not with enough resolution to realize the small corner change would cause a different hit. I also ran into this with my own algorithm, and increased the resolution to get the correct answer. However, mine has other flaws that I haven't worked out yet and need to debug. I have to shelve this for a while to work on other stuff.

 

Line2D doesn't have an intersectXXX method.

 

Corbin

0 Likes
Message 6 of 10

MichaelT_123
Advisor
Advisor

As you seem to be capable... of writing your own numerical algorithm, try:

  • Find the closest point to the curve and use it as the starting approximation in fsolve()
  • With a failed "solve", run the process on a couple of approximation points lying on the curve
  • change fsolve() algorithm and/or change iteration parameters.

Regards

MichaelT

MichaelT
0 Likes
Message 7 of 10

BrianEkins
Mentor
Mentor

Another option is to call the evaluator property of the curve to obtain a CurveEvaluator3D, then use the getStrokes method to obtain a polyline approximation of the curve. Then the intersection becomes a line-line intersection.

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

corbin2
Enthusiast
Enthusiast

Thanks Brian - that sounds like a better idea than what I was doing! I'll experiment with this idea when I get back into it.

0 Likes
Message 9 of 10

Closed-Loop-Bot
Autodesk
Autodesk
Accepted solution
We're happy to report this issue has been resolved. Update Fusion to the most recent version to apply the fix. If this update resolved your issue, feel free to click the "Accept Solution" button to help other community members find the answer more easily. If the issue persists after updating, don't hesitate to reach out to us by replying to this thread. We're here to help! Let us know if you need any further assistance!
0 Likes
Message 10 of 10

corbin2
Enthusiast
Enthusiast

Awesome, this looks to be fixed, thank you!

0 Likes