Function Syntax: ImportBlockDrw https://www.lee-mac.com/copyblockfromdrawing.html id: importblock01 title: ImportBlock short_description: ๐Ÿš€ ImportBlock is an AutoCAD and Civil 3D AutoLISP utility for importing selected block definitions from an external DWG, DWT, or DWS file into the active drawing. It uses a generated DCL dialog, ObjectDBX access, optional insertion, scale controls, UCS-aware rotation, saved settings, and safe source drawing validation. command: ๐Ÿงฐ Load the LISP with APPLOAD, then run IB or ImportBlock. The command asks for a source DWG, DWT, or DWS file, lists importable blocks, and can insert the selected block reference after import. Important functions: c:ib, c:ImportBlock, LM:GetDocumentObject, ib:import-block-definition, ib:list-importable-blocks, and ib:write-dcl. description: ๐Ÿ“˜ This AutoLISP program helps AutoCAD and Civil 3D users reuse block definitions from external drawings without manually opening and copying from the source file. ๐Ÿ” The user selects a source drawing and chooses a block from a DCL list of importable block definitions. ๐Ÿง  The tool reads the external drawing through ObjectDBX and copies the selected block definition into the active drawing. ๐Ÿ“ Optional insertion supports uniform scale, separate X/Y/Z scale, current UCS rotation alignment, and current model space or paper space placement. ๐Ÿ’พ ImportBlock.cfg stores the previous source drawing, selected block, scale options, dialog location, and user toggles for repeat workflows. ๐Ÿ”ด Existing block names are not overwritten. Blocks already present in the active drawing are filtered out of the import list. helper_function: ๐Ÿง  Safe string and type guards - ib:strp, ib:string, ib:nonblank-str-p, ib:num-p, and related helpers prevent Boolean T or NIL values from being passed into string-only AutoLISP calls. ๐Ÿ“ Configuration persistence - ib:read-cfg, ib:save-cfg, ib:cfg-path, and ImportBlock.cfg store the last source drawing, selected block, scale options, insert option, UCS rotation option, confirmation setting, message setting, and dialog position. ๐Ÿงฉ Generated DCL interface - ib:write-dcl builds a temporary DCL dialog with a unique dialog name each run, reducing dialog-name collisions and supporting repeatable UI loading. ๐Ÿ“Œ Dialog position memory - ib:done-dialog, ib:normalize-dlgpt, and the saved DLGX/DLGY values preserve dialog placement across command runs and AutoCAD sessions. ๐Ÿ” External drawing scan - LM:GetDocumentObject opens the selected drawing through an existing document reference or ObjectDBX so block definitions can be read without manually opening the source DWG. ๐Ÿงน Importable block filtering - ib:list-importable-blocks excludes xrefs, layout blocks, anonymous blocks, externally referenced names, and block names that already exist in the active drawing. ๐Ÿ“ค Block definition copy - ib:import-block-definition deep-copies the selected block definition from the ObjectDBX drawing into the active drawing Blocks collection. ๐Ÿ“ UCS-aware insertion - ib:ucs-rotation, trans, ib:current-space, and vla-insertblock support insertion in the current model space or paper space context while respecting current UCS orientation when requested. ๐Ÿ”’ Runtime cleanup - The local *error* handler releases ObjectDBX objects, unloads DCL resources, deletes temporary DCL files, and reports non-cancel errors safely. functionalities: ๐Ÿš€ Import blocks from external drawings - select a source DWG, DWT, or DWS and copy a chosen block definition into the active AutoCAD or Civil 3D drawing. ๐Ÿงฉ DCL block picker - display available importable block definitions in a practical dialog instead of requiring manual block table browsing. ๐Ÿ” Filter unsafe or unavailable definitions - skip layout blocks, xrefs, anonymous blocks, externally referenced names, and definitions already present in the current drawing. ๐Ÿ“Œ Optional immediate insertion - import only the block definition or insert a block reference immediately after import. ๐Ÿ“ Scale control - use uniform XYZ scale or separate Scale X, Scale Y, and Scale Z values for inserted block references. ๐Ÿงญ UCS rotation alignment - align inserted blocks to the current UCS when the Align rotation to current UCS option is enabled. ๐Ÿ“ Confirm before import - use an optional confirmation prompt before copying the selected block definition into the active drawing. ๐Ÿ’พ Saved settings - remember source path, last block, scale options, toggles, and dialog position in ImportBlock.cfg. ๐Ÿ”„ ObjectDBX workflow - read external drawing block definitions efficiently without forcing the user to open the source drawing in the editor. ๐ŸŸข Non-destructive source handling - the selected source drawing is read for block definitions while the source file itself is not modified. result: โœ… The final result is a faster AutoCAD and Civil 3D block import workflow for reusable DWG content, production drawings, and CAD library management. It reduces repetitive manual block import steps and improves drawing setup speed, block standardization, and DWG management quality. additional_info: ๐Ÿ”ด The routine imports only definitions that do not already exist in the active drawing. ๐ŸŸง The selected external drawing is read as a source and is not modified. ๐Ÿ“Œ If insertion is cancelled, the block definition may still remain imported. ๐Ÿ”’ Requires AutoCAD or Civil 3D support for DCL, Visual LISP COM, and ObjectDBX.