Inserts a drawing file or a named block that has been defined in the current drawing.
Supported platforms: Windows only
VBA:
RetVal = object.InsertBlock(InsertionPoint, Name [, Xscale [, Yscale [, ZScale [, Rotation [, Password]]]]])
Type: Block, ModelSpace, PaperSpace
The objects this method applies to.
Access: Input-only
Type: Variant (three-element array of doubles)
The 3D WCS coordinates specifying the location in the drawing to insert the block.
Access: Input-only
Type: String
The name of the AutoCAD drawing file or the name of the block to insert. If it is a file name, include the .dwg extension and any path information necessary for AutoCAD to find the file.
Access: Input-only; optional
Type: Double
The default equals 1.0. Must be a positive number.
Access: Input-only; optional
Type: Double
The default equals 1.0. Must be a positive number.
Access: Input-only; optional
Type: Double
The default equals 1.0. Must be a positive number.
Access: Input-only; optional
Type: Double
The default equals 0.0 radians.
Access: Input-only; optional
Type: Variant
The password that was applied to the drawing file when it was saved.
Inserting a block into another block will create nested blocks.
Attempting to call the InsertBlock method with an uninitialized Name parameter results in unexpected behavior.
VBA:
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
Visual LISP:
(vl-load-com) (defun c:Example_InsertBlock() ;; This example creates a block containing a circle. ;; It then inserts the block. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Create the block (setq insertionPnt (vlax-3d-point 0 0 0)) (setq blockObj (vla-Add (vla-get-Blocks doc) insertionPnt "CircleBlock")) ;; Add a circle to the block (setq center (vlax-3d-point 0 0 0) radius 1) (setq circleObj (vla-AddCircle blockObj center radius)) ;; Insert the block (setq insertionPnt (vlax-3d-point 2 2 0)) (setq modelSpace (vla-get-ModelSpace doc)) (setq blockRefObj (vla-InsertBlock modelSpace insertionPnt "CircleBlock" 1 1 1 0)) (vla-ZoomAll acadObj) )