;V.2.3.UNMI.LSP copyright 5/14/05
;Bill DeShawn is not responsible for any damage caused by this program.
;Use at your own risk
; Little modification by Igal Averbuh 2016
(defun unmierr (msg)
(redraw)
(setvar "snapmode" snmode)
(setvar "osmode" os)
(setq os nil snmode nil ol nil bname nil firstlay nil b-ent nil b-list nil sset nil sslen nil index nil ent nil elist nil oldmi nil ip nil changed nil)
(setq *error* olderr)
(princ msg)
(command "_.undo" "_end")
(prompt ". Please try again.")
(princ)
)
(defun c:um (/ os snmode ol bname firstlay b-ent b-list sset sslen index ent elist oldmi scl ip changed)
(command "_.undo" "_g")
(setq olderr *error*)
(setq *error* unmierr)
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(setq snmode (getvar "snapmode"))
(setvar "snapmode" 0)
(setq ol (getvar "clayer"))
(graphscr)
(setq bname (getstring "\nName of block to unmirror : "))
(if (= bname "")(setq bname nil))
(while (and (null b-ent) (null bname))
(setq b-ent (entsel))
(if b-ent
(progn
;(prompt "\nPlease wait... ") this doesn't work until the end of routine.
(setq b-list (cdr (entget (car b-ent))))
(setq bname (cdr (assoc 2 (cdr b-list))))
(setq firstlay (cdr (assoc 8 (cdr b-list))))
(command "_.layer" "s" firstlay "")
)
)
)
(setq sset (ssget "x" (list (cons 2 bname))))
(if sset
(progn
(setq sslen (sslength sset))
(setq index 0)
(repeat sslen
(setq ent (ssname sset index))
(setq elist (entget ent))
(setq oldmi (assoc 41 elist))
(if (not (minusp (cdr oldmi)))
(setq oldmi (assoc 43 elist))
)
(setq laname (cdr (assoc 8 elist)))
(setq scl (abs (cdr oldmi)))
(setq ip (assoc 10 elist))
(if (minusp (cdr oldmi))
(progn
(command "_.-layer" "t" laname "on" laname "s" laname "")
; (command "_.delay" "500")
(command "_.mirror" ent "" (cdr ip) "@12<90" "y")
; (if (and (null changed)(/= (getvar "clayer") firstlay))(setq changed T))
(if (/= (getvar "clayer") firstlay)(setq changed T))
)
)
(setq index (1+ index))
)
)
)
(if changed
(progn
;(command "_.delay" "500")
(command "_.layerp")(command "_.layerp")
(princ "\nSome layer(s) may have been thawed and turned on \nto un-mirror blocks. Layers have been returned to previous status.")
)
)
(command "_.layer" "s" ol "")
(setq *error* olderr)
(setvar "snapmode" snmode)
(setvar "osmode" os)
(redraw)
(command "_.undo" "end")
(princ)
)
(princ "\nUNMI.LSP V.2.3 - Loaded! Author: Bill DeShawn")

Advertisements