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.

# Points along a Curve

frank_weeks
Member, Developers Posts:

**6**EDU
I am new to FeatureScript and am looking to create a (seemingly) simple script that places points along a curve, evenly spaced. Without getting into other spacing options, I would first like some guidance on how to do this given only a distance and a quantity, starting from the end.

I tried to dissect the very nice Curve Pattern FeatureScript but there were so many options, I couldn't figure out what part of the code actually does the measuring along the path.

I figure I would use evLength and opPoint (and some math) but that's about as far as I've gotten. Any suggestions to help me move forward would be greatly appreciated.

I tried to dissect the very nice Curve Pattern FeatureScript but there were so many options, I couldn't figure out what part of the code actually does the measuring along the path.

I figure I would use evLength and opPoint (and some math) but that's about as far as I've gotten. Any suggestions to help me move forward would be greatly appreciated.

Tagged:

0

## Comments

1,9031,636The code for this should be fairly simple.

First, you want to get the total length of the curve with evLength.

Once you have the length of the curve, you can calculate something like 'var parameterPerLength = 1.0/totalLength'. Every curve in onshape is parameterized from 0.0 to 1.0, so this scaling factor lets you convert from distance into parameter space. For example, if a curve is 10m long, and you want to find the point that is 5m along the curve, you would calculate that as 'desired parameter = 5m * (1 / 10m) = 0.5' (incidentally this is the same as just dividing by the total length, but I prefer to store my scale factors in separate variables).

Now that you have a scale factor, you can fill an array with all the parameters along the curve that you want to find the point at. Define a constant 'var spacing = <distance between points> * parameterPerLength'. This is the around of parameterization between each point you want to create. Then, use a for loop to fill an array with [1 * spacing, 2 * spacing, 3 * spacing, etc]. It will probably be best not to not exceed a parameter of 1.0 in this array.

Call evEdgeTangentLines with your edge and your array of parameters, making sure to set 'arcLengthParameterization' to 'true'. This call will return you an array of Line objects such that 'returnFromEv[0].origin' and 'returnFromEv[1].origin' will give you the first and second points along the line at your specified distance apart.

call opPoint with all of those Line origins.

Let me know if you can work this out Happy to write you a quick FeatureScript to do it but it seemed like you wanted to do it yourself.

6EDU