Community
Civil 3D Customization
cancel
Showing results for
Show  only  | Search instead for
Did you mean:

## Get point at 3D Distance along feature line

7 REPLIES 7
SOLVED
Message 1 of 8
1255 Views, 7 Replies

## Get point at 3D Distance along feature line

Hi,

I'm trying to get a point at a 3D distance along a feature line. Currently, there is a method under the Feature Line class that allows you to get a point at a distance along the feature line, called " GetPointAtDist ". There is also a method called " Get3dDistanceAtPoint ".

I notice that the GetPointAtDist method gets the point on the feature line at the 2D projected distance, with its associated elevation on the feature line. Is there any documentation on how this method works? Is it measuring a chord distance of the feature line, or taking feature line points and interpolating between them? I am inclined to use the feature line, since I need to work with the true 3D distance of an alignment and its profile, rather than the projected distance. This gets more important when there are curves in the alignment and profile, and I need to measure true 3d distance along the curves with a small amount of tesselation.

Civil 3D's Point Creation Tools using Measure feature line object or Divide feature line object does not work for my purposes (I need points at varying 3D distances along the object).

Does anyone have any suggestions on a better way to do this using the .NET API?

Any help would be appreciated!

Thanks!

7 REPLIES 7
Message 2 of 8

I am pretty sure the GetPointAtDist() is the 2d distance along the feature.

I am sure someone else out there will have a more elegant method, but I would create a new extension method to calculate the point at a 3d distance along the feature. In my quick tests this seems to work.

```/// <summary>
/// Returns the 3d length of a feature segment. Will return 0 if
/// used on any invalid feature parameter and calculating more than 1.0 segments
/// at a time will return an incorrect calculation.
/// </summary>
private static double SegmentLength3d( this Feature feature, double startparam, double endparam ) {
try {
// get the change in elevation from
var elevChange = feature.GetPointAtParameter( startparam )[2] - feature.GetPointAtParameter( startparam + endparam )[2];
// get the 2d length of segment
var segLen2d = feature.GetDistanceAtParameter( startparam ) - feature.GetDistanceAtParameter( startparam + endparam );
// pythagorean theorem calulates the 3d length since features don't contain spline elements
return Math.Sqrt( Math.Pow( elevChange, 2 ) + Math.Pow( segLen2d, 2 ) );
} catch ( Exception ) {
return 0;
}
}

/// <summary>
/// Returns the 3d length of a feature segment. Will return 0 if
/// used on any invalid feature parameter.
/// </summary>
/// <param name="param">The parameter of the feature for which you want the
/// length of the segment following. E.G. entering 1.0 will return the length
/// of the parameter from 1.0 to 2.0.</param>
private static double SegmentLength3d( this Feature feature, double param ) {
return feature.SegmentLength3d( param, 1.0 );
}

public static Point3d GetPointAtDist3d( this Feature feature, double distance3d ) {
double totalLen = 0;
for ( double i = 0.0; i < feature.EndParam; i++ ) {
var segLen = feature.SegmentLength3d( i );
if ( distance3d >= totalLen && distance3d < totalLen + segLen ) {
var distInSeg = distance3d - totalLen;
return feature.GetPointAtParameter( i + (distInSeg / segLen) );
} else {
totalLen += segLen;
}
}
return default;
}```
Message 3 of 8
Anonymous

I HAVE THE SAME ISSUE , CAN SOMEONE HELP ME TO SOLVE IT, HOW to do this using the .NET API?

Message 4 of 8

@Anonymous what is wrong with the response given by @tyronebk ? It appears to do what you asked for.

Jeff_M, also a frequent Swamper
Message 5 of 8
Anonymous

Sir , I m not Much Professional in civil 3d and I don't know how to implement this solution.IF you Could Help me By Telling , How to apply in Civil 3d API.net

Message 6 of 8

@Anonymous, create a new class,

``````public static class FeatureExtensions
{
}``````

then, with your Featureline you have a new method to use:

``   var pt = featureline.GetPointAtDist3d(123.45);``
Jeff_M, also a frequent Swamper
Message 7 of 8

Thanks for your response - and sorry for my late reply. I was using a similar method to calculate 3D distance, but it became a bit challenging for vertical curves and horizontal curves, especially with the spirals. So instead of inquiring from the feature line, for which I have limited control of tessellation, I generated a set of points at much higher sampling resolution that reads directly from the profile and alignment. Note that, in true 3D, the horizontal geometry locations are shifted (i.e. Tangent-to-Spiral), and the shift will continue to accumulate - and the rate at which it accumulates varies with vertical curvature. Also, I had some issues with the rotation matrices so I wrote my own for 3D rotation.

izzy

Message 8 of 8