Trim 3D Polyline

Trim 3D Polyline

jhdempsey
Advocate Advocate
4,218 Views
3 Replies
Message 1 of 4

Trim 3D Polyline

jhdempsey
Advocate
Advocate

Hi All

 

Whats the best method to trim a 3D Polyline?

Ive already worked out the points where i want the trimmed polyline to start and end, but im struggling to find out a way to perform the actual trim.

I tried setting the StartPoint and EndPoint properties to the points i wanted, but that gives a NotImplementedException error, and all other examples on this forum seem to relate to 2D or LW polylines which didnt work for 3D polylines or the methods/properties used dont exist on a 3D polyline

 

Anyone able to help?

0 Likes
Accepted solutions (1)
4,219 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant
Accepted solution

Hi,

 

I would use the GetSplitCurves() method.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 4

heyimsp12
Enthusiast
Enthusiast

Hi @_gile 

 

Since GetSplitCurves() method is available for Polyline2d as well, I'm assuming the same can be done for 2d Polylines. However, I always run into eInvalidInput error and I don't understand why. Could you help? 

 

//Here is my piece of code.
Plane xyPlane = new Plane(Point3d.Origin, Vector3d.ZAxis);
var proj_EyePath = (Polyline2d)EyePathCurve.GetProjectedCurve(xyPlane, Vector3d.ZAxis);

//Trim EyePath
//Here StartPoint and EndPoint are two 3d Points.
Point3dCollection splitPoints = new Point3dCollection();
splitPoints.Add(proj_EyePath.GetClosestPointTo(StartPoint, false));
splitPoints.Add(proj_EyePath.GetClosestPointTo(EndPoint, false));

DBObjectCollection splitCurves = proj_EyePath.GetSplitCurves(splitPoints); //Error: Invalid Input
0 Likes
Message 4 of 4

norman.yuan
Mentor
Mentor

You may want to try to reverse the order of adding split points to the splitPoints collection.

 

If there is multiple split points, the points added to the Point3dCollection should be sorted ascendingly by the distance to the start point of the curve being split.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes