VB编程改变AutoCAD圆对象的圆形坐标和半径
2011-06-12 21:04 精诚所至 金石为开 阅读(760) 评论(0) 编辑 收藏 举报通过设置圆和圆弧实体的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