关于分解块引用 (VBA/ActiveX)
使用该方法中断块引用。Explode 通过分解块参照,可以修改块,或者添加或删除定义块的对象。 显示分解块参照的结果此示例创建一个块,并在该块的定义中添加一个圆圈。然后,将块作为块参照插入到图形中。然后分解块参照,并显示分解过程生成的对象及其对象类型。 Sub Ch10_ExplodingABlock() ' Define the block Dim blockObj As AcadBlock Dim insertionPnt(0 To 2) As Double insertionPnt(0) = 0 insertionPnt(1) = 0 insertionPnt(2) = 0 Set blockObj = ThisDrawing.Blocks.Add _ (insertionPnt, "CircleBlock") ' Add a circle to the block Dim circleObj As AcadCircle Dim center(0 To 2) As Double Dim radius As Double center(0) = 0 center(1) = 0 center(2) = 0 radius = 1 Set circleObj = blockObj.AddCircle(center, radius) ' Insert the block Dim blockRefObj As AcadBlockReference insertionPnt(0) = 2 insertionPnt(1) = 2 insertionPnt(2) = 0 Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _ (insertionPnt, "CircleBlock", 1#, 1#, 1#, 0) ZoomAll MsgBox "The circle belongs to " & blockRefObj.ObjectName ' Explode the block reference Dim explodedObjects As Variant explodedObjects = blockRefObj.Explode ' Loop through the exploded objects Dim I As Integer For I = 0 To UBound(explodedObjects) explodedObjects(I).Color = acRed explodedObjects(I).Update MsgBox "Exploded Object " & I & ": " _ & explodedObjects(I).ObjectName explodedObjects(I).Color = acByLayer explodedObjects(I).Update Next End Sub 父主题: |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 22:13
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.