InsertBlock Method

Back to Methods Reference

Inserts a drawing file or a named block that has been defined in the current drawing.

Signature

VBA :RetVal = object.InsertBlock(InsertionPoint, Name, Xscale, Yscale, ZScale, Rotation)

VL : RetVal = (vla-InserBlock object InsertionPoint, Name, Xscale, Yscale, ZScale, Rotation)

(vla-InsertBlock mspace ip thename xscale yscale zscale rot)

  • Object : ModelSpace, PaperSpace, Block
    The object or objects this method applies to.

  • InsertionPoint : Variant (three-element array of doubles); input-only
    The 3D WCS coordinates specifying the location in the drawing to insert the block.

  • Name : String; input-only
    The name of the AutoCAD drawing file or the name of the block to insert. If it is a file name, include any path information necessary for AutoCAD to find the file and the .dwg extension.

  • Xscale : Double; input-only; optional
    The default equals 1.0. Must be a positive number.

  • Yscale : Double; input-only; optional
    The default equals 1.0. Must be a positive number.

  • Zscale : Double; input-only; optional
    The default equals 1.0. Must be a positive number.

  • Rotation : Double; input-only; optional
    The default equals 0.0 radians.

  • RetVal : BlockRef object
    The placed block as a Block Reference object.

Remarks

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.

Example :


(defun c:al-insertblock ()

(vl-load-com)

(setq thisdrawing (vla-get-activedocument 
                      (vlax-get-acad-object)))

(setq mspace (vla-get-modelspace thisdrawing))

(setq util (vla-get-utility thisdrawing))

(setq ip (vla-GetPoint util nil "\nInsertion Point: "))

(setq thename (vla-GetString util 1 "\nBlock Name: "))

(setq xscale (vla-GetReal util "\nX Scale Factor : "))

(setq yscale (vla-GetReal util "\nY Scale Factor : "))

(setq zscale (vla-GetReal util "\nZ Scale Factor : "))

(setq rot (vla-GetReal util "\nRotation Angle : "))

(setq theblock (vla-InsertBlock mspace ip 
                      thename xscale yscale zscale rot))

(princ)

);defun

 
The AutoLisp/Visual Lisp/VBA Resource Website
Google
Search the WWW Search AfraLisp

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website