Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape, CAD, maker project and design.

First time visiting? Here are some places to start:

  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Curve Length

public_publicpublic_public Member Posts: 5 PRO
Please suggest a method to measure the distance along a curve between specified points.
Thank you

Comments

  • MBartlett21MBartlett21 Member Posts: 1,388 EDU
    @public_public
    Could you show an example
    MB - I make FeatureScripts: view FS (My FS's have "Official" beside them)
  • public_publicpublic_public Member Posts: 5 PRO
    FeatureScript 920;
    import(path : "onshape/std/geometry.fs", version : "920.0");

    annotation { "Feature Type Name" : "CurveLength" }
    export const CurveLength = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
    annotation { "Name" : "Point_1", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }
    definition.Point_1 is Query;

    annotation { "Name" : "Point_2", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }
    definition.Point_2 is Query;

    }
    {
    var myStartPoint is Vector = evVertexPoint(context, {
    "vertex" : qNthElement(definition.Point_1, 0)
    });

    var myEndPoint is Vector = evVertexPoint(context, {
    "vertex" : qNthElement(definition.Point_2, 0)
    });
    var myCurveF is Query = qContainsPoint(qEverything(EntityType.EDGE), myStartPoint);
    var myCurve is Query = qContainsPoint(myCurveF, myEndPoint);
    var Length_1 is ValueWithUnits = evLength(context, {
    "entities" : myCurve
    });

    debug(context, Length_1);

    });


    "evLength" only evaluates total length. But I need calculate the length between any points on the curve.





  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 1,882
    I’d be interested in a solution to this. All I can think of is to:
    1. Iterate over the curve to find the parameter closest to each point using evEdgeTangentLine
    2. Compare parameters against overall curve length 

    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • public_publicpublic_public Member Posts: 5 PRO
    Currently I'm using the same approach. But looks like it is a little bit slow. evLength works faster. I iterate over 10 000 points to get necessary tolerance. It is nice to get the reverse function to evEdgeTangentLine.

  • owen_sparksowen_sparks Member, Developers Posts: 1,949 PRO
    edited October 2018
    Could you project it onto a new temp sketch, split it, measure it, delete the sketch?  No iterations that way.  Edit - Dumb Idea

    Owen S.
    Production Engineer
    HWM-Water Ltd
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 1,882
    @owen_sparks I’m guessing it may not be a 2D curve

    @public_public I will post a faster solution soon
    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • public_publicpublic_public Member Posts: 5 PRO
    It looks like a 3D curve can not be split for some reason. The curve's split issue already arose here

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 1,882
    @public_public - a little more involved than I first thought, but fast and accurate 



    https://cad.onshape.com/documents/d103e50535cbfbf38dd6e51b


    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • public_publicpublic_public Member Posts: 5 PRO
    Thanks for your support!
Sign In or Register to comment.