How to compare PathEntities to sketch curves

metd01567
Advocate Advocate
681 Views
3 Replies
Message 1 of 4

How to compare PathEntities to sketch curves

metd01567
Advocate
Advocate

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.

0 Likes
Accepted solutions (1)
682 Views
3 Replies
Replies (3)
Message 2 of 4

metd01567
Advocate
Advocate

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.

0 Likes
Message 3 of 4

BrianEkins
Mentor
Mentor
Accepted solution

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.

 

http://modthemachine.typepad.com/files/mathgeometry.pdf

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

metd01567
Advocate
Advocate

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

0 Likes