- 积分
- 10513
- 明经币
- 个
- 注册时间
- 2002-6-3
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-5-10 09:56:00
|
显示全部楼层
可以参考帮助文件。
AddArc 给定圆心、半径、起点角度和端点角度来创建圆弧。
Sub Example_AddArc()
' This example creates an arc in model space.
Dim arcObj As AcadArc
Dim centerPoint(0 To 2) As Double
Dim radius As Double
Dim startAngleInDegree As Double
Dim endAngleInDegree As Double
' Define the circle
centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
radius = 5#
startAngleInDegree = 10#
endAngleInDegree = 230#
' Convert the angles in degrees to angles in radians
Dim startAngleInRadian As Double
Dim endAngleInRadian As Double
startAngleInRadian = startAngleInDegree * 3.141592 / 180#
endAngleInRadian = endAngleInDegree * 3.141592 / 180#
' Create the arc object in model space
Set arcObj = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngleInRadian, endAngleInRadian)
ZoomAll
End Sub
用户可以按照环形阵列或矩形阵列来复制对象。对于环形阵列,可以控制对象的副本数目和填充阵列的角度;对于矩形阵列,可以控制行数和列数以及它们之间的距离。
要创建环形阵列,请使用该对象的 ArrayPolar 方法。这个方法需要三个输入值:要创建的对象数目、填充角度和阵列的中心点。
本例创建一个圆,然后对圆执行环形阵列操作。这个过程将围绕基点 (4,4,0),在 180 度内创建四个圆。
Sub Ch4_ArrayingACircle()
' 创建圆
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 = 1
Set circleObj = ThisDrawing.ModelSpace. _
AddCircle(center, radius)
ZoomAll
' 定义环形阵列
Dim noOfObjects As Integer
Dim angleToFill As Double
Dim basePnt(0 To 2) As Double
noOfObjects = 4
angleToFill = 3.14 ' 180 度
basePnt(0) = 4#: basePnt(1) = 4#: basePnt(2) = 0#
' 下例通过绕点 (3,3,0) 旋转和
' 复制对象而创建四个
' 对象副本。
Dim retObj As Variant
retObj = circleObj.ArrayPolar _
(noOfObjects, angleToFill, basePnt)
ZoomAll
End Sub
要创建二维或三维矩形阵列,请使用该对象的 ArrayRectangular 方法。这个方法需要输入四个值:行数、列数、行间距和列间距。在创建三维数组时,还需要指定层数以及层间距。
本例创建一个圆,然后对该圆执行矩形阵列操作,创建 5 行 5 列的圆。
Sub Ch4_ArrayRectangularExample()
' 创建圆
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)
ZoomAll
' 定义矩形阵列
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 = 5
numberOfColumns = 5
numberOfLevels = 2
distanceBwtnRows = 1
distanceBwtnColumns = 1
distanceBwtnLevels = 1
' 创建对象的阵列
Dim retObj As Variant
retObj = circleObj.ArrayRectangular _
(numberOfRows, numberOfColumns, numberOfLevels, _
distanceBwtnRows, distanceBwtnColumns, distanceBwtnLevels)
ZoomAll
End Sub |
|