在三维空间中创建阵列

AutoCAD ActiveX/VBA

 
在三维空间中创建阵列
 
 
 

使用 ArrayRectangular 方法可以在三维空间中创建矩形阵列。除了指定列数(X 方向)和行数(Y 方向)以外,还要指定层数(Z 方向)。

有关在三维中使用对象阵列的详细信息,请参见《用户手册》中的“创建对象阵列”。

创建三维矩形阵列

本样例创建一个圆,然后用该圆创建四行、四列、三层的圆的矩形阵列。

Sub Ch8_CreateRectangularArray()
    ' 创建圆
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 2: center(1) = 2: center(2) = 0
    radius = 0.5
    Set circleObj = ThisDrawing.ModelSpace. _
                              AddCircle(center, radius)
      
    ' 定义矩形阵列
    Dim numberOfRows As Long
    Dim numberOfColumns As Long
    Dim numberOfLevels As Long
    Dim distanceBwtnRows As Double
    Dim distanceBwtnColumns As Double
    Dim distanceBwtnLevels As Double
    numberOfRows = 4
    numberOfColumns = 4
    numberOfLevels = 3
    distanceBwtnRows = 1
    distanceBwtnColumns = 1
    distanceBwtnLevels = 4
      
    ' 创建对象的阵列
    Dim retObj As Variant
    retObj = circleObj.ArrayRectangular _
        (numberOfRows, numberOfColumns, _
         numberOfLevels, distanceBwtnRows, _
         distanceBwtnColumns, distanceBwtnLevels)
    ZoomAll
End Sub