Home > Software engineering >  AutoCAD VBA
AutoCAD VBA

Time:10-27

How to get a straight line from the two endpoint coordinates?

CodePudding user response:

Acadline object the startpoint of the endpoint and attribute. Every point with variant variables to receive, to receive after variant variables will become a double array containing three elements, three elements in the array are respectively that point of X, Y, Z coordinates

CodePudding user response:

Give you a instance

 Sub Example_EndPoint () 
'This example creates an elliptical arc and then
'finds the coordinates of its start and end points.
Dim ellObj As AcadEllipse
Dim majAxis (0 To 2) As a Double
Dim center (0 To 2) As a Double
Dim radRatio As Double
Dim the startPoint As the Variant
Dim the endPoint As the Variant

'Create an ellipse in model space
Center (0)=# 5: center (1)=# 5: center (2)=0 #
MajAxis (0)=10: majAxis (1)=# 20: majAxis (2)=0 #
RadRatio=0.3
The Set ellObj=ThisDrawing. ModelSpace. AddEllipse (center, majAxis, radRatio)

'Enter a start Angle of 45 degrees, and an end Angle of 270 degrees
EllObj. StartAngle=45 * (3.14/180)
EllObj. EndAngle=270 * (3.14/180)
ZoomAll

'the Find the start and endpoints for the ellipse
The startPoint=ellObj. The startPoint
The endPoint=ellObj. The endPoint
MsgBox "This the ellipse has a start point of" & amp; The startPoint (0) & amp; ", "& amp; The startPoint (1) & amp; ", "& amp; The startPoint (2) & amp; "And an endpoint of" & amp; The endPoint (0) & amp; ", "& amp; The endPoint (1) & amp; ", "& amp; The endPoint (2), vbInformation, "endPoint Example"
End Sub

CodePudding user response:

In fact there is another way, I also give you a instance

 Sub Example_GetBoundingBox () 
'This example creates a line in model space. It then finds the
'bounding box for the line and displays the corners of the box.

Dim the startPoint (0 To 2) As a Double
Dim the endPoint (0 To 2) As a Double
Dim lineObj As AcadLine

'Create the Line object in model space
The startPoint (0)=2 # : the startPoint (1)=2 # : the startPoint (2)=0 #
The endPoint (0)=# 4: the endPoint (1)=# 4: the endPoint (2)=0 #
The Set lineObj=ThisDrawing. ModelSpace. AddLine (the startPoint of the endPoint)
ZoomAll

Dim minExt As the Variant
Dim maxExt As the Variant

'Return the bounding box for the line and Return the minimum
'and maximum extents of the box in the minExt and maxExt variables.
LineObj. GetBoundingBox minExt, maxExt

'Print the min and Max extents
MsgBox "The extents of The bounding box for line are:" & amp; VbCrLf _
& "Min among:" & amp; MinExt (0) & amp; ", "& amp; MinExt (1) & amp; ", "& amp; MinExt (2) _
& VbCrLf & amp; "Max among:" & amp; MaxExt (0) & amp; ", "& amp; MaxExt (1) & amp; ", "& amp; MaxExt (2), vbInformation, "GetBoundingBox Example"

End Sub
  •  Tags:  
  • VBA