通过设置圆和圆弧实体的Center、Radius属性,可以改变其圆心坐标和半径值,通过返回其属性值,可以获取其圆心坐标和半径值。
下面的代码将模型空间的所有圆向上移动100的单位,并将半径减为原来的一半。
Private Sub Command1_Click()
Dim i As Integer
Dim currcenterpt As Variant
Dim newcenterpt(0 To 2) As Double
Dim rad As Double
For i = 0 To acadapp.ActiveDocument.ModelSpace.Count – 1
If acadapp.ActiveDocument.ModelSpace(i).EntityType = acCircle Then
currcenterpt = acadapp.ActiveDocument.ModelSpace(i).center
rad = acadapp.ActiveDocument.ModelSpace(i).radius
newcenterpt(0) = currcenterpt(0)
newcenterpt(1) = currcenterpt(1) + 100
newcenterpt(2) = currcenterpt(2)
rad = rad / 2
acadapp.ActiveDocument.ModelSpace(i).center = newcenterpt
acadapp.ActiveDocument.ModelSpace(i).radius = rad
acadapp.ActiveDocument.ModelSpace(i).Update
End If
Next i
End Sub