AddMInsertBlock Method (ActiveX)

Inserts an array of blocks.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.AddMInsertBlock(InsertionPoint, Name, XScale, YScale, ZScale, Rotation, NumRows, NumColumns, RowSpacing, ColumnSpacing [, Password])
object

Type: Block, ModelSpace, PaperSpace

The objects this method applies to.

InsertionPoint

Access: Input-only

Type: Variant (three-element array of doubles)

The 3D WCS coordinates at which to insert the array of blocks.

Name

Access: Input-only

Type: String

The name of the MInsertBlock.

Note: You cannot precede the name of an MInsertBlock with an asterisk to separate the block's objects during insertion, as you can with a standard Block.
XScale

Access: Input-only

Type: Double

The X scale factor.

YScale

Access: Input-only

Type: Double

The Y scale factor.

ZScale

Access: Input-only

Type: Double

The Z scale factor.

Rotation

Access: Input-only

Type: Double

The rotation angle in radians.

NumRows

Access: Input-only

Type: Long

A positive integer representing the number of rows for the array.

NumColumns

Access: Input-only

Type: Long

A positive integer representing the number of columns for the array.

RowSpacing

Access: Input-only

Type: Double

The distance between the array rows.

ColumnSpacing

Access: Input-only

Type: Double

The distance between the array columns.

Password

Access: Input-only

Type: Variant

The password that is required to open and insert the drawing.

Return Value (RetVal)

Type: MInsertBlock

The newly created array of blocks.

Remarks

The following illustration shows an array of inserted blocks.



Original block



Array of inserted blocks

Examples

VBA:

Sub Example_AddMInsertBlock()
    ' This example creates a new Block in the current drawing, adds a
    ' Circle object to the new block, and uses the newly created block
    ' to create a rectangular array of block references using AddMInsertBlock
    
    Dim circleObj As AcadCircle
    Dim centerPoint(0 To 2) As Double, InsertPoint(0 To 2) As Double
    Dim radius As Double
    Dim newMBlock As AcadMInsertBlock
    Dim newBlock As AcadBlock
    
    ' Define the Circle object that will be inserted into the block
    centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0
    InsertPoint(0) = 1: InsertPoint(1) = 1: InsertPoint(2) = 0
    radius = 0.5
    
    ' Create a new block to hold the Circle object
    Set newBlock = ThisDrawing.Blocks.Add(centerPoint, "CBlock")
    
    ' Add the Circle object to the new block object
    Set circleObj = ThisDrawing.Blocks("CBlock").AddCircle(centerPoint, radius)
    
    ' Create a rectangular array of Circles using the new block containing the Circle
    ' and the AddMInsertBlock method
    Set newMBlock = ThisDrawing.ModelSpace.AddMInsertBlock(InsertPoint, "CBlock", 1, 1, 1, 1, 2, 2, 1, 1)
        
    ThisDrawing.Application.ZoomAll
    
    MsgBox "A rectangular array has been created from the original block."

End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddMInsertBlock()
    ;; This example creates a new Block in the current drawing, adds a
    ;; Circle object to the new block, and uses the newly created block
    ;; to create a rectangular array of block references using AddMInsertBlock
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the Circle object that will be inserted into the block
    (setq centerPoint (vlax-3d-point 0 0 0)
          InsertPoint (vlax-3d-point 1 1 0)
          radius 0.5)
    
    ;; Create a new block to hold the Circle object
    (setq blocks (vla-get-Blocks doc))
    (setq newBlock (vla-Add blocks centerPoint "CBlock"))
    
    ;; Add the Circle object to the new block object
    (setq circleObj (vla-AddCircle newBlock centerPoint radius))
    
    ;; Create a rectangular array of Circles using the new block containing the Circle
    ;; and the AddMInsertBlock method
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq newMBlock (vla-AddMInsertBlock modelSpace InsertPoint "CBlock" 1 1 1 1 2 2 1 1))
        
    (vla-ZoomAll acadObj)
    
    (alert "A rectangular array has been created from the original block.")
)