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.
Curve Length
public_public
Posts: 5 ✭
Please suggest a method to measure the distance along a curve between specified points.
Thank you
0
Comments
-
@public_public
Could you show an example0 -
FeatureScript 920;<br>import(path : "onshape/std/geometry.fs", version : "920.0");<br><br>annotation { "Feature Type Name" : "CurveLength" }<br>export const CurveLength = defineFeature(function(context is Context, id is Id, definition is map)<br> precondition<br> {<br> annotation { "Name" : "Point_1", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }<br> definition.Point_1 is Query;<br><br> annotation { "Name" : "Point_2", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }<br> definition.Point_2 is Query;<br><br> }<br> {<br> var myStartPoint is Vector = evVertexPoint(context, {<br> "vertex" : qNthElement(definition.Point_1, 0)<br> });<br><br> var myEndPoint is Vector = evVertexPoint(context, {<br> "vertex" : qNthElement(definition.Point_2, 0)<br> });<br> var myCurveF is Query = qContainsPoint(qEverything(EntityType.EDGE), myStartPoint);<br> var myCurve is Query = qContainsPoint(myCurveF, myEndPoint);<br> var Length_1 is ValueWithUnits = evLength(context, {<br> "entities" : myCurve<br> });<br><br> debug(context, Length_1);<br><br> });<br><br>"evLength" only evaluates total length. But I need calculate the length between any points on the curve.
0 -
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
Senior Director, Technical Services, EMEA1 -
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.
0 -
Could you project it onto a new temp sketch, split it, measure it, delete the sketch? No iterations that way. Edit - Dumb IdeaOwen S.Business Systems and Configuration Controller
HWM-Water Ltd1 -
Senior Director, Technical Services, EMEA1
-
It looks like a 3D curve can not be split for some reason. The curve's split issue already arose here
0 -
@public_public - a little more involved than I first thought, but fast and accurate

https://cad.onshape.com/documents/d103e50535cbfbf38dd6e51b
Senior Director, Technical Services, EMEA1 -
Thanks for your support!
-1 -
@NeilCooke or anyone who knows enough about FeatureScripts -- (I'm learning but I'm not that familiar yet!), if you had a chance would you be able to make it so that FS saves the curve length value in a new variable?
Basically I'm modeling a drive belt with two different-sized pulleys, so I want to measure the exact length of the belt and then save use that length in the part number -- so if anyone knows of a different way to do that, I'd be open to that too. Thank you!
Posted too soon, just found a FS that does exactly what I'm asking:
https://cad.onshape.com/documents/d8a36f7517523544158ae686/w/b257afccef639b5ffa33e3fe/e/a2254749aecfdeb3b2c601c50 -
@NeilCooke -- your script works great when measuring between two points that fall within a curve. In selecting the end points of a curve, the script returns an error. Please see pic below. Purely informative, although I wouldn't cry if you made a fix : ) Thank you,NeilCooke said:@public_public - a little more involved than I first thought, but fast and accurate
https://cad.onshape.com/documents/d103e50535cbfbf38dd6e51b
Ted
0




