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: 

How to compare PathEntities to sketch curves

Message 1 of 4
379 Views, 3 Replies

How to compare PathEntities to sketch curves

I've created a path from a user selected SketchCurve, using the tangentChainCurves option.  I'd like to find out where along the Path the user selected SketchCurve lies.


When I iterate on the Path object, I get PathEntities, which (I think) are transient curves derived from the chained SketchCurves.  That makes sense as the path should be a sequence of curves with a common direction, and SketchCurve direction isn't deterministic.  Fortunately PathEntities have an entity member that "gets the sketch curve or edge this entity was derived from."  I printed the classType of the first entity was SketchLine, which is correct for my sketch.  I tried iterating through the Path, and casting its entities as SketchCurve, in the hope an equality operator might detect identity with my original SketchCurve.  Doesn't seem to work though.


    segCount = 0
    for thisSegment in path:
        thisCurve = adsk.fusion.SketchCurve.cast(thisSegment.entity)
        ui.messageBox("curve type: " + thisCurve.classType())
        if thisCurve == selectedCurve:
            ui.messageBox ("found the user's SketchCurve: ", str(segCount))
        segCount += 1

I could compare start/end points, but that's messy and I think I'm missing something.


I'd also like to understand evaluators better, maybe I could use them for my purpose.  What is a CurveEvaluator3D "parameter position"?  I thought it might be length along the curve, but if that were true the "getLengthAtPosition" method wouldn't make sense.

Message 2 of 4
in reply to: metd01567

Well, it turns out that code was actually working.  I seemed to be getting inconsistent results, but it turns out the order of curves in a Path can reverse, depending on which curve was used to create it.  I won't mark my own post as a solution, though, since I didn't answer my question about evaluators.

Message 3 of 4
in reply to: metd01567

Here's a link to a paper I wrote for a class at Autodesk University 10 years ago that discusses the evaluator concept for the Inventor API.  The concepts are the same for Fusion 360, so hopefully, it will help.

Brian Ekins
Inventor and Fusion 360 API Expert
Message 4 of 4
in reply to: BrianEkins

I took the red pill, now everything looks different in parameter space.  Thanks.

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