Sorry this is a bit rough, I was in a hurry.
Begin NestedLayerControl.lsp
;|
c:llo turn a layer off by selecting a nested entity
c:llk lock a layer by selecting a nested entity
c:llf freeze a layer by selecting a nested entity
c:llu unlock a layer by selecting a nested entity
c:llp Set layer plotting on by selecting a nested entity
c:llnp Set layer plotting off by selecting a nested entity
c:vplf ViewPort Layer Freeze by selecting a nested entity
nlf nested layer functions
ezl:nllist dialog box routine used for nlf
|;
(defun c:llo ( ;turn a layer off by selecting a nested entity
/ ;no formal arguments
) ;no local variables
(nlf "OFF" T)
(princ)
) ;end llo
(defun c:llk ( ;lock a layer by selecting a nested entity
/ ;no formal arguments
) ;no local variables
(nlf "LOCK" T)
(princ)
) ;end llk
(defun c:llnp( ;Turn off plotting by selecting a nested entity
/ ;no formal arguments
) ;no local variables
(nlf '("P" "NoPlot") T)
(princ)
)
(defun c:llp( ;Turn plotting on by selecting a nested entity
/ ;no formal arguments
) ;no local variables
(nlf '("P" "Plot") T)
(princ)
)
(defun c:vplf(
/
)
(nlf "VPLFREEZE" T)
(princ)
)
(defun c:llf ( ;freeze a layer by selecting a nested entity
/ ;no formal arguments
) ;no local variables
(nlf "FREEZE" T)
(princ)
) ;end llf
(defun c:llu ( ;unlock a layer by selecting a nested entity
/ ;no formal arguments
) ;no local variables
(nlf "UNLOCK" T)
(princ)
) ;end llU
(defun nlf ( ;nested layer functions
which ;text string for the layer command
nestedp ;true to work on nested layers, nil otherwise
/ ;end of formal argument list
blipmode cmdecho echo elist ent layer prmpt temp
) ;end of local variable list
(cond
;;linetype change
((and (listp which) (= "L" (strcase (car which))))
(setq
prmpt (strcat "change to linetype " (cadr which))
echo (strcat "changed to " (cadr which) " linetype.")
)
)
((and (listp which) (= "P" (strcase (car which))))
(setq
prmpt (strcat "set to " (cadr which))
echo (strcat "Set to " (cadr which) ".")
)
)
((listp which)
(alert "Unhandled list as argument WHICH in EZLayer nlf function.")
)
((equal "OFF" which)
(setq
prmpt "turn off:"
echo "turned off."
) ;_ end of setq
)
((equal "FREEZE" which)
(setq
prmpt "freeze:"
echo "frozen."
) ;_ end of setq
)
((equal "LOCK" which)
(setq
prmpt "lock:"
echo "locked."
) ;_ end of setq
)
((equal "UNLOCK" which)
(setq
prmpt "unlock:"
echo "unlocked."
) ;_ end of setq
)
((equal "VPLFREEZE" which)
(setq
prmpt "freeze in current viewport:"
echo "frozen in current viewport:"
)
)
((equal "Plot Off" which)
(setq
prmpt "Turn plotting off:"
echo "Plotting turned off: ")
)
((equal "Plot On" which)
(setq
prmpt "Turn plotting on:"
echo "Plotting turned on: ")
)
(T exit)
) ;end cond
(cond
((and
(null nestedp)
(setq ent (entsel (strcat "Pick entity on layer to " prmpt)))
)
(setq
elist (entget (car ent))
layer (cdr (assoc 8 elist))
)
) ;end null nestedp
((and
(setq ent (nentsel (strcat "Pick entity on layer to " prmpt)))
(setq temp (ezl:nllist ent))
(/= 0 (car temp))
) ;end and
(setq layer (cadadr temp))
)
(T (alert "\nInvalid value in nlp function.")(exit))
)
;end nestedp
(if (and
(= (strcase layer) (getvar "clayer"))
(= which "FREEZE")
)
(progn
(princ "\nSetting current layer to 0. ")
(setvar "clayer" "0")
)
)
(progn
(setq
blipmode (getvar "blipmode")
cmdecho (getvar "cmdecho")
) ;_ end of setq
(setvar "cmdecho" 1);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setvar "blipmode" 0)
(cond
;;linetype
((and
(listp which)
(member (strcase (car which)) '("L" "P"))
)
(command "layer" (car which) (cadr which) layer "")
)
((listp which)
(alert "Unhandled list for WHICH argument in nlf function.")
)
;;basic layer command
((member which '("FREEZE" "OFF" "LOCK" "UNLOCK" ))
(command "layer" which layer "")
)
;;vplayer freeze
((= which "VPLFREEZE")
(if (= 0 (getvar "tilemode"))
(command "vplayer" "f" layer "" "")
(alert "This command must have tilemode set to 0")
)
)
(T (alert (strcat "Invalid function name: " which " in nlf function in ezlutils.lsp")))
)
(setvar "blipmode" blipmode)
(setvar "cmdecho" cmdecho)
(princ (strcat "\nLayer " layer " " echo))
(setvar "cmdecho" cmdecho)
(setvar "blipmode" blipmode)
) ;end progn
(princ)
) ;end nlf
(defun ezl:nllist ( ;list the layers of a nested entity
sellist ;list returned by nentsel
/ ;end of formal argument list
elayer ;nested function
nlist:fill_list ;nested function
entlist llist dcl_id
listitem which
) ;end of local variable list
(defun elayer ( ;return the entity type and layer name
ent ;entity name
/ ;end of formal argument list
elist
layer
etype
) ;end of local variable list
(setq
elist (entget ent)
layer (cdr (assoc 8 elist))
etype (cdr (assoc 0 elist))
etype (cond
((= "INSERT" etype)
(strcat
"Block "
(cdr (assoc 2 elist))
" insertion"
) ;_ end of strcat
)
((= "ATTDEF" etype)
"Attribute Definition"
)
((= "ATTRIB" etype)
"Attribute"
)
((= "BODY" etype)
"3D Solid"
)
(T etype)
) ;_ end of cond
) ;end setq
(list etype layer)
) ;end elayer
(defun nllist:fill_list ( ;fill the layers list box
llist ;list of layers and entity descriptions
listbox-key ;the key for the listbox
/ ;end of formal argument list
) ;end of local variable list
(start_list listbox-key)
(foreach ent llist
(add_list (strcat
(cadr ent) ;layer name
"\t "
(car ent) ;entity description
) ;end strcat
) ;end add_list
) ;end foreach
(end_list)
llist
) ;_ end of defun
(if (<= 4 (length sellist))
(setq entlist (cons (car sellist) (last sellist)))
(setq entlist (list (car sellist)))
) ;_ end of if
(setq
llist (mapcar 'elayer entlist)
dcl_id (load_dialog "nllist.dcl")
) ;_ end of setq
(if (not (new_dialog "setlayer" dcl_id))
(exit)
) ;_ end of if
(action_tile "layer_list" "(setq listitem $value)")
(nllist:fill_list llist "layer_list")
(setq
listitem (get_tile "layer_list")
which (start_dialog)
) ;_ end of setq
(done_dialog)
(unload_dialog dcl_id)
(list which (nth (atoi listitem) llist))
) ;end ezl:nllist
Begin NLList.dcl
dcl_settings : default_dcl_settings { audit_level = 3; }
setlayer : dialog {
initial_focus = "layer_list" ;
key = "chlayer" ;
label = "Select layer" ;
: list_box {
allow_accept = true ;
key = "layer_list" ;
label = "Layers" ;
mnemonic = "L" ;
width = 96 ;
height = 32;
tabs ="16 24 32";
}
ok_cancel ;
}