本帖最后由 hellomoshi 于 2019-4-13 19:25 编辑
大家好! 我在用《vb参考》中的Example_InsertBlock()示例的时候,当radius=1时运行没有问题,当改为radius=2再次运行,发现radius=1的circle还在创建的参考块中。我尝试用 for each blockobj in thisdrawing.blocks
blockobj.delete
next block
删除的时候,提示“对象被参考”,无法被删除。
请问这种问题怎么解决呢?我要让输出的结果是acadblockref对象,所以不考虑用explode炸开再删除的方法。 - Sub Example_InsertBlock()
- ' This example creates a block containing a circle.
- ' It then inserts the block.
- ' Create 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
-
- End Sub
|