输入 3D 世界坐标系 (WCS) 坐标类似于输入 2D WCS 坐标。 除了指定 X 和 Y 值外,还可以指定 Z 值。与 2D 坐标一样,变体用于将坐标传递给 ActiveX® 方法和属性,并查询坐标。 定义和查询 2D 和 3D 折线的坐标本示例创建两条折线,每条折线都有三个坐标。第一条折线是 2D 折线,第二条折线是 3D 折线。请注意,在创建 3D 折线时,包含顶点的数组的长度将展开以包括 Z 坐标。该示例最后查询折线的坐标并在消息框中显示坐标。 Sub Ch8_Polyline_2D_3D()
Dim pline2DObj As AcadLWPolyline
Dim pline3DObj As AcadPolyline
Dim points2D(0 To 5) As Double
Dim points3D(0 To 8) As Double
' Define three 2D polyline points
points2D(0) = 1: points2D(1) = 1
points2D(2) = 1: points2D(3) = 2
points2D(4) = 2: points2D(5) = 2
' Define three 3D polyline points
points3D(0) = 1: points3D(1) = 1: points3D(2) = 0
points3D(3) = 2: points3D(4) = 1: points3D(5) = 0
points3D(6) = 2: points3D(7) = 2: points3D(8) = 0
' Create the 2D light weight Polyline
Set pline2DObj = ThisDrawing.ModelSpace. _
AddLightWeightPolyline(points2D)
pline2DObj.Color = acRed
pline2DObj.Update
' Create the 3D polyline
Set pline3DObj = ThisDrawing.ModelSpace. _
AddPolyline(points3D)
pline3DObj.Color = acBlue
pline3DObj.Update
' Query the coordinates of the polylines
Dim get2Dpts As Variant
Dim get3Dpts As Variant
get2Dpts = pline2DObj.Coordinates
get3Dpts = pline3DObj.Coordinates
' Display the coordinates
MsgBox ("2D polyline (red): " & vbCrLf & _
get2Dpts(0) & ", " & get2Dpts(1) & vbCrLf & _
get2Dpts(2) & ", " & get2Dpts(3) & vbCrLf & _
get2Dpts(4) & ", " & get2Dpts(5))
MsgBox ("3D polyline (blue): " & vbCrLf & _
get3Dpts(0) & ", " & get3Dpts(1) & ", " & _
get3Dpts(2) & vbCrLf & _
get3Dpts(3) & ", " & get3Dpts(4) & ", " & _
get3Dpts(5) & vbCrLf & _
get3Dpts(6) & ", " & get3Dpts(7) & ", " & _
get3Dpts(8))
End Sub
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 08:43
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.