Midpoint of polylines

Is there a way of getting the midpoints of multiple polylines that have been selected by layer?

Select polylines
Then geometry
Use note
Curve.PointAtParameter

Note that PointAtParameter may not be the middle length, but anywhere along the length of the curve. Parameterization is ‘% of the forces which generate the curve’, not ‘% of the length’.

This is particularly true in civil projects where curves are more likely to be non-uniform. Anything spline shaped or reporting as a ‘NURBS’ curve should cause a bit of caution in this respect.

To ensure you are at the ‘middle of the overall length’, you can instead use a Curve.Length node to get the length of the curve, a division node to get half of the resulting length, and a Curve.PointAtSegmentLength node to find the midpoint.

4 Likes

I usually rebuild the curve first becoz the curve may not be parametrized

I’ve not tested lately, but a while ago I noticed that there is a difference between the API and Dynamo in this approach. While in the API each segment of a Polyline starts with a new parameter, Dynamo uses one parameter for the whole Polycurve.

Yes - different applications parameterize things differently. AutoCAD (the application in use when talking polylines, civil consumes that API) doesn’t treat them continuously. In this case we’re discussing Dynamo tools though so I assumed that we had Dynamo geometry rather than AutoCAD ones.

Also Revit doesn’t usually permit non-uniform curves, so the parameterization is directly related to percentage of the length in most cases. This was done as the concepts are difficult to explain and parameterization is given in two methods in the Revit user interface. I am not sure if AutoCAD parameters are forced to be uniform or not.

He/she was talking about polylines on layers, so that means AutoCAD objects :slight_smile:
So calculating the mid could be done with a node that uses a Polycurve representation, or with Python which can work with the Polyline object directly.

I think it is saver to not use parameterization, the Length property and a PointAtDistance (API) or PointAtSegmentLength (Dynamo) is a good choice.

(Although a Length property of a Civil 3D Profile arc segment in the API is the 2D length and not the curve length, so as a general advice: check everything!)

2 Likes