如何得到一條直線的兩個端點坐標?
uj5u.com熱心網友回復:
acadline物件的startpoint屬性和endpoint屬性.每個點都用變體變數接收,接收后變體變數會變為含有三個元素的雙精度陣列,陣列中三個元素分別是該點的X,Y,Z坐標uj5u.com熱心網友回復:
給你個實體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 Double
Dim center(0 To 2) As Double
Dim radRatio As Double
Dim startPoint As Variant
Dim endPoint As 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
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
' Find the start and endpoints for the ellipse
startPoint = ellObj.startPoint
endPoint = ellObj.endPoint
MsgBox "This ellipse has a start point of " & startPoint(0) & ", " & startPoint(1) & ", " & startPoint(2) & " and an endpoint of " & endPoint(0) & ", " & endPoint(1) & ", " & endPoint(2), vbInformation, "EndPoint Example"
End Sub
uj5u.com熱心網友回復:
其實還有另外中方式,我也給你個實體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 startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
Dim lineObj As AcadLine
' Create the Line object in model space
startPoint(0) = 2#: startPoint(1) = 2#: startPoint(2) = 0#
endPoint(0) = 4#: endPoint(1) = 4#: endPoint(2) = 0#
Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
ZoomAll
Dim minExt As Variant
Dim maxExt As 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 the line are:" & vbCrLf _
& "Min Extent: " & minExt(0) & "," & minExt(1) & "," & minExt(2) _
& vbCrLf & "Max Extent: " & maxExt(0) & "," & maxExt(1) & "," & maxExt(2), vbInformation, "GetBoundingBox Example"
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/139602.html
標籤:VBA
上一篇:按查詢的結果參考的代碼
