(defun c:abb ( / *error* blk obj ins sel ) (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (cond ( (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (getvar 'clayer)))))) (princ "\nCurrent layer locked.") ) ( (progn (while (progn (setvar 'errno 0) (initget "Browse Rotation") (princ (strcat "\nAutomatic Block Rotation: " (getenv "LMac\\ABBRotation"))) (setq sel (entsel (strcat "\nSelect Block [Browse/Rotation]" (if (= "" (setq blk (getvar 'insname))) ": " (strcat " <" blk "> : ") ) ) ) ) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, Try Again.") ) ( (null sel) (if (= "" blk) (setq blk nil) ) ) ( (= "Rotation" sel) (initget "ON OFF") (setenv "LMac\\ABBRotation" (cond ( (getkword (strcat "\nAutomatic Block Rotation [ON/OFF] <" (getenv "LMac\\ABBRotation") ">: " ) ) ) ( (getenv "LMac\\ABBRotation") ) ) ) ) ( (= "Browse" sel) (setq blk (getfiled "Select Block" "" "dwg" 16)) nil ) ( (listp sel) (if (/= "INSERT" (cdr (assoc 0 (entget (car sel))))) (princ "\nObject must be a block.") (setq obj (vla-copy (vlax-ename->vla-object (car sel))) blk nil ) ) ) ) ) ) (not (or blk obj)) ) ) ( (setq ins (getpoint "\nSpecify Point for Block: ")) (LM:startundo (LM:acdoc)) (if (null obj) (setq obj (vla-insertblock (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)) (vlax-3D-point (trans ins 1 0)) blk 1.0 1.0 1.0 (angle '(0.0 0.0 0.0) (trans (getvar 'ucsxdir) 0 (trans '(0.0 0.0 1.0) 1 0 t) t)) ) ) ) (if blk (setvar 'insname (vl-filename-base blk))) (vla-put-insertionpoint obj (vlax-3D-point (trans ins 1 0))) (LM:AutoBlockBreak (vlax-vla-object->ename obj) (= "ON" (getenv "LMac\\ABBRotation"))) (LM:endundo (LM:acdoc)) ) ) (princ) )