抱歉!我上面的回复是有问题的!
单独的改变块参照中的实体的属性而不涉及改变其块定义,我实现不了。不和哪位高人可以?
Sub dd() Dim nCount As Integer '计数器 Dim pObject As AcadObject '对象定义 Dim pBlock As AcadBlock '块定义 Dim pBlockRef As AcadBlockReference '块参照 Dim pntPickPoint As Variant '返回的PICKPOINT Dim strBlockName As String '块名 Dim pCircle As AcadCircle '圆实体 On Error GoTo errHandle ThisDrawing.Utility.GetEntity pBlockRef, pntPickPoint, "选择一个块参照:" '用户选择,具体参数的含义参照AUTOCAD帮助 '下面判断用户选择的是否是一个块参照对象 If pBlockRef.ObjectName <> "AcDbBlockReference" Then MsgBox "你选择的不是块参照!" Exit Sub '选择的不是块参照,退出 End If '选择了一个块参照 '修改这个块参照对象所依附的!!!!!块定义!!!!!!!中的圆的半径 '看看autocad自带的_REFEDIT命令的运行结果,大致可以知道块定义和块参照以及MODELSPACE之间的关系 strBlockName = pBlockRef.Name '得到块名 nCount = 0 Set pBlock = ThisDrawing.Blocks.Item(strBlockName) For Each pObject In pBlock If pObject.ObjectName = "AcDbCircle" Then Set pCircle = pObject pCircle.Radius = pCircle.Radius + 10 '圆的半径+10 nCount = nCount + 1 '统计圆实体的个数 End If Next '执行完循环体后,块定义被改变了!!!!!!!!! ThisDrawing.Regen acActiveViewport Exit Sub errHandle: '错误处理 MsgBox Err.Description End Sub |