Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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?
joshtargo
Member Posts: 230 EDU
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] });
0
Answers
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.
Custom FeatureScript and Onshape Integrated Applications
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