;;;========================================================================
;;; *** LYR-UNHIDE.LSP ***
;;;========================================================================
;;;
;;; This function dynamicaly "TURN ON" frozen layers by selecting objects
;;; lying on these layers. The procedure is achieved by temporary turning
;;; on all layers to enable selection.
;;;
;;;
;;; "Specially recommanded to use on Xrefs" - Raymond Rizkallah, Aug. 2007
;;;========================================================================
(defun C:LUH (/ entsll laynam laypmt )
(setq orgm (getvar "regenmode"))
(setq laylst nil laypmt " ")
(command "undo" "m" "undo" "g")
(setvar "regenmode" 1)
(command "layer" "t" "*" "on" "*" "")
(while
(setq entsll (nentsel "\n Select object on layer to be unhidden: "))
(setq laynam (cdr (assoc 8 (entget (car entsll)))))
(if (null laylst) (setq laylst (strcat laynam ",")) (setq laylst (strcat laylst laynam ",")))
;(prompt (strcat "\n <" (substr laylst 1 (1- (strlen laylst))) ">"))
(setq laypmt (strcat laypmt "<" laynam "> ; ")) (prompt (strcat "\n" laypmt))
) ;end while
; (command "undo" "end" "undo" "1")
(if laylst (command "layer" "t" laylst "on" laylst "u" laylst "")) ;end if
(setvar "regenmode" orgm)
(princ)
) ;end function
;;;========================================================================
(prompt "\n Use [C:LUH] to dynamicaly reveal hidden layers. ")
(princ)
I´m little confuse what you want to do ... is it another to isolate or unisolate layers?
@stefan, what does your routine do? i've tried it and it does nothing...or maybe i've done something wrong....Works only for frozen layers. On error (or hitting escape) will turn on temporary hidden layers, but will keep changes already made.
To answer your fist post, try thisCode - Auto/Visual Lisp: [Select]
;;;======================================================================== ;;; *** LYR-UNHIDE.LSP *** ;;;======================================================================== ;;; ;;; This function dynamicaly "TURN ON" frozen layers by selecting objects ;;; lying on these layers. The procedure is achieved by temporary turning ;;; on all layers to enable selection. ;;; ;;; ;;; "Specially recommanded to use on Xrefs" - Raymond Rizkallah, Aug. 2007 ;;;======================================================================== ) ;(prompt (strcat "\n <" (substr laylst 1 (1- (strlen laylst))) ">")) ) ;end while ; (command "undo" "end" "undo" "1") ) ;end function ;;;========================================================================
; error: An error has occurred inside the *error* functiontoo few arguments
(defun c:layallon ()
(vlax-for lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
(vla-put-layeron lay :vlax-true)
)
(princ)
)
Where are these routines?
layerstate-has
layerstate-save
(vl-load-com)
(defun c:LayAllThaw ()
(vlax-for lay (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-put-Freeze lay :vlax-false))
(princ))
(defun c:LayAllOn ()
(vlax-for lay (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-put-LayerOn lay :vlax-true))
(princ))
(defun c:LayAllShow () (c:LayAllThaw) (c:LayAllOn))
(setq *LayUnHide-StateName* "*LayerUnHide*")
(defun c:LayUnHide (/ *error* LayersToTurnOn en)
(defun *error* (msg)
(if (layerstate-has *LayUnHide-StateName*)
(progn (layerstate-restore *LayUnHide-StateName* nil) (layerstate-delete *LayUnHide-StateName*)))
(cond ((or (not msg) (wcmatch (strcase msg) "*EXIT*,*QUIT*,*ABORT*"))))
(t (prompt (strcat "*** Error: " msg " ***"))))
(princ))
(layerstate-save *LayUnHide-StateName* 3 nil)
(c:LayAllShow)
(while (setq en (entsel "\nSelect object on layer to unhide: "))
(setq LayersToTurnOn (cons (cdr (assoc 8 (entget en))) LayersToTurnOn)))
(*error* nil)
(vlax-for lay (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (vl-position (vla-get-Name lay) LayersToTurnOn)
(progn (vla-put-LayerOn lay :vlax-true) (vla-put-Freeze lay :vlax-false))))
(princ))
(if (layerstate-has *LayUnHide-StateName*)
(progn (layerstate-restore *LayUnHide-StateName* nil) (layerstate-delete *LayUnHide-StateName*)))
(vl-catch-all-apply '(lambda ()
(if (layerstate-has *LayUnHide-StateName*)
(progn (layerstate-restore *LayUnHide-StateName* nil) (layerstate-delete *LayUnHide-StateName*)))
))
OK, fixed it ... sorry real stupid mistakes. Comes from trying to program without debugging inside VLIDE.Code - Auto/Visual Lisp: [Select]Firstly the cond inside the *error* handler was simply incorrect! 2nd had to add the catch into the All on/thaw defuns. 3rd add a regen after thawing. And lastly car of the entsel :-[
(layerstate-delete *LayUnHide-StateName*))) (layerstate-save *LayUnHide-StateName* 3 nil) (c:LayAllShow) (*error* nil)
Command: layunhide
Regenerating model.
Command:
Select object on layer to unhide:
Select object on layer to unhide:
*** Error: Automation Error. Invalid layer ***
I don't know what to tell you. It seems to work fine here in ACA 2013 (sorry don't have a Vanilla here) ... for a while. Though sometimes I have to do it twice to the same layer before it catches. It's as if the first time round the layer doesn't allow itself to be "shown", but the second time round it says: "Agh alright ... if you want it so much then FINE!!!" :realmad: Bloody lazy layers :pissed:
It doesn't happen on all layers, just some of them. I can't figure out why this happens. Nothing locked or any such. It seems to happen on layers which were frozen or off - makes no difference. Anyone know why this occurs?