Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

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.

How do I get the endpoints of a curve?

joshtargojoshtargo Member Posts: 230 EDU
edited October 7 in FeatureScript

I want to have point1 and point2 default to the endpoints of the already selected curve. but if someone picks new points explicitly, it will use those chosen points.

I am editing a fork of transformCopy.fs

    annotation { "Name" : "Entities to transform or copy",
                 "Filter" : (EntityType.BODY || (BodyType.MATE_CONNECTOR && InContextObject.NO)) && AllowMeshGeometry.YES && SketchObject.NO,
                 "UIHint" : UIHint.PREVENT_CREATING_NEW_MATE_CONNECTORS }
    definition.entities is Query;
later:……

const endpoints = evaluateQuery(context, definition.scaleEndpoints); // Calculate the chord vector from the two selected points const point1 = evVertexPoint(context, { "vertex" : endpoints[0] }); const point2 = evVertexPoint(context, { "vertex" : endpoints[1] });

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 169 PRO

    Since you are already creating code that takes in two vertices, you could find them from an edge using
    qAdjacent(yourEdgeQuery, AdjacencyType.VERTEX, EntityType.VERTEX);
    An edge will always have only 2 adjacent vertices that are its endpoint.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • Jacob_CorderJacob_Corder Member Posts: 137 PRO

    also evEdgeTangentLines with parameters [0,1] will give you the points at the end. the array is of lines so it is startPoint = tl[0].origin. endPoint = tl[1].origin

Sign In or Register to comment.