(defun C:DIMMIRROR (/ ;;local symbols ename ent gripset i flag j oldeko olderr ss ;;local functions ++ *lerror* ) ;;local error handler (defun *lerror* (msg) (if (member msg '("console break" "Function cancelled")) (princ) (princ (strcat "\nError " (itoa (getvar "ERRNO")) ": " msg)) ) ;if ;;restore old error handler (setq *error* olderr olderr nil ) (princ) ) ;*lerror* ;; ++ Increment counter &a . ;;;call: (++ 'a) <<--note the quote! (defun ++ (&a) (set &a (1+ (eval &a))) ) ;end of ++ ;;support for noun-verb selection ;;save a selection set of any gripped objects (setq gripset (cadr (ssgetfirst))) ;;start an UNDO group, which cancels grips (command "._UNDO" "_GROUP") ;;install local *error* function (setq olderr *error* *error* *lerror* ) ;;if gripset exists (if gripset ;;step through gripset and modify any DIMENSION entities found (progn (setq i 0 j 0 ss (ssadd) ) (while (< i (sslength gripset)) (setq ename (ssname gripset i)) (if (= "DIMENSION" (cdr (assoc 0 (setq ent (entget ename))))) (progn (entmod (subst (cons 51 (- (cdr (assoc 51 ent)) PI)) (assoc 51 ent) ent ) ) (++ 'j) ) ;progn ) ;if (++ 'i) ) ;while (princ (strcat "\nMaßzahl bei " (itoa j) " Bemaßungen.") ) ;;nil ss & set flag to set up for the case of null gripset (setq ss nil flag T ) ) ;progn ;;otherwise prompt user to select DIMENSIONS to change (progn (prompt "\nBemaßung(en) für den Spiegelvorgang auswählen: " ) (setq ss (ssget '((0 . "DIMENSION")))) ) ; ) ;if ;;process all entities in the resulting selection set (if ss (progn (setq i 0) (while (< i (sslength ss)) (setq ent (entget (ssname ss i))) (entmod (subst (cons 51 (- (cdr (assoc 51 ent)) PI)) (assoc 51 ent) ent ) ) (++ 'i) ) ;while (princ (strcat "\nMaßzahl gespiegelt bei " (itoa (sslength ss)) " Bemaßungen." ) ) ) ;progn (if (null flag) (princ "\nKeine gültige Bemaßung ausgewählt!") ) ) ;if ;;restore previous error function (setq *error* olderr) ;;switch off CMDECHO while ending the UNDO group (setq oldeko (getvar "CMDECHO")) (setvar "CMDECHO" 0) (command "._UNDO" "_END") (setvar "CMDECHO" oldeko) ;restore old CMDECHO value (princ) ;quiet exit )