Redefine a Block

AutoCAD ActiveX

 
Redefine a Block
 
 
 

Use any of the Block object methods and properties to redefine a block. When you redefine a block, all the references to that block in the drawing are immediately updated to reflect the new definition.

Redefinition affects previous and future insertions of a block. Constant attributes are lost and replaced by any new constant attributes. Variable attributes remain unchanged, even if the new block has no attributes.

Redefine the objects in a block definition

This example creates a block and adds a circle to the definition of the block. The block is then inserted into the drawing as a block reference. The circle in the block definition is updated, and the block reference is updated automatically.

Sub Ch10_RedefiningABlock()
 ' 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
 
 ' Redefine the circle in the block,
 ' and update the block reference
 circleObj.radius = 3
 blockRefObj.Update
End Sub