PolyLine and Point2D and Point3D

PolyLine and Point2D and Point3D

conveyor1
Enthusiast Enthusiast
2,751 Views
5 Replies
Message 1 of 6

PolyLine and Point2D and Point3D

conveyor1
Enthusiast
Enthusiast

Afternoon,

 

I have written some code to select a polyline and then assign the various points in the polyline to new variables.  However, I am running into the issue where the data I am getting from the polyline is 2d and the items downstream require 3D.

 

Here is an example:

Dim myPLine As Polyline

dim Num_Points as integer = myPLine.NumberOfVertices

Dim Point1 As New Geometry.Point2d     ' Needs to be .Point3d to work with the .Line command

Point1 = myPLine.GetPoint2dAt(Count)

Dim Myline1 As New DatabaseServices.Line(Point1, Point2)

 

In this case, everything up to the "Dim Myline1" works with 2d, but the line command requires 3d.

 

Does anyone have an solutions for this.

 

Please let me know when you can.

0 Likes
Accepted solutions (2)
2,752 Views
5 Replies
Replies (5)
Message 2 of 6

ActivistInvestor
Mentor
Mentor
Accepted solution

You can use the GetPoint3dAt() method to get the WCS coordinate of a vertex.

 


@conveyor1wrote:

Afternoon,

 

I have written some code to select a polyline and then assign the various points in the polyline to new variables.  However, I am running into the issue where the data I am getting from the polyline is 2d and the items downstream require 3D.

 

Here is an example:

Dim myPLine As Polyline

dim Num_Points as integer = myPLine.NumberOfVertices

Dim Point1 As New Geometry.Point2d     ' Needs to be .Point3d to work with the .Line command

Point1 = myPLine.GetPoint2dAt(Count)

Dim Myline1 As New DatabaseServices.Line(Point1, Point2)

 

In this case, everything up to the "Dim Myline1" works with 2d, but the line command requires 3d.

 

Does anyone have an solutions for this.

 

Please let me know when you can.


 

0 Likes
Message 3 of 6

conveyor1
Enthusiast
Enthusiast
Morning,

Good call out and i did try this. However, if I switch, I then loose out
on the functionality of this line of code:

Angle2 = Point2.GetVectorTo(Point3).Angle

Do you know an equivalent to this calculation for the 3D option?

Please let me know your thoughts.
0 Likes
Message 4 of 6

_gile
Consultant
Consultant
Accepted solution

Hi,

 

You should have a look at the Vector3d.GetAngleTo() method.

 

Assuming all the points lies on a plane parallel to the WCS XY plane, the equivalent for Vector2d.Angle should be:

Angle2 = Vector3d.XAxis.GetAngleTo(Point2.GetVectorTo(Point3), Vector3d.ZAxis);


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 6

ActivistInvestor
Mentor
Mentor

Go back and read your original question. 

 

You didn't ask how to calculate angles between 3D coordinates, you asked how to get polyline vertices as 3D coordinates.

 


@conveyor1 wrote:
Morning,

Good call out and i did try this. However, if I switch, I then loose out
on the functionality of this line of code:

Angle2 = Point2.GetVectorTo(Point3).Angle

Do you know an equivalent to this calculation for the 3D option?

Please let me know your thoughts.

 

 

0 Likes
Message 6 of 6

Izhar_Azati
Advocate
Advocate

Note that if you use GetPoint2dAt, you get a point in ECS rather than WCS as you get from GetPoint3dAt

0 Likes