Lisp-Adding to a Selection Set
Lisp-Adding to a Selection Set
(OP)
I'd like to take the LayerIsolate lisp routine from the Express Tools and modify it. We use 4 layers for one component, we call them layer groups. So for the component 1, the 4 actual layers needed to show the part are: layer 1s is solid lines only, layer 1c is centerlines only, layer 1h is hidden lines only, and layer 1p is phantom lines only. I would like to control the visibility of each group all together.
So what I want is a LayerIsolateGroup routine that will look at the selected items, and keep those layers on as well as the ?s, ?c, ?h, and ?p layers for each selection.
Here's the code to get the graphical selections:
Any idea how to add the additional layer names to LAYLST (or maybe LAY...I'm not really sure but I think LAYLST)? I think that is what I want to do because later in the code are these 3 lines:
I've also found this to check whether a layer exists (NEWLAYER in this example):
(setq flag (tblsearch "LAYER" "NEWLAYER"))
And this for the string length:
strlen
Thanks,
Ken
So what I want is a LayerIsolateGroup routine that will look at the selected items, and keep those layers on as well as the ?s, ?c, ?h, and ?p layers for each selection.
Here's the code to get the graphical selections:
CODE
(if (not (setq SS (ssget "_i")))
(progn
(prompt "\nSelect object(s) on the layer(s) to be isolated: ")
(setq SS (ssget))
)
)
(if SS
(progn
(setq CNT 0)
(while (and ss
(> (sslength ss) 0)
(setq LAY (ssname SS CNT))
);and
(setq LAY (cdr (assoc 8 (entget LAY))))
(if (not (member LAY LAYLST))
(setq LAYLST (cons LAY LAYLST))
)
(setq CNT (1+ CNT))
)
(progn
(prompt "\nSelect object(s) on the layer(s) to be isolated: ")
(setq SS (ssget))
)
)
(if SS
(progn
(setq CNT 0)
(while (and ss
(> (sslength ss) 0)
(setq LAY (ssname SS CNT))
);and
(setq LAY (cdr (assoc 8 (entget LAY))))
(if (not (member LAY LAYLST))
(setq LAYLST (cons LAY LAYLST))
)
(setq CNT (1+ CNT))
)
Any idea how to add the additional layer names to LAYLST (or maybe LAY...I'm not really sure but I think LAYLST)? I think that is what I want to do because later in the code are these 3 lines:
CODE
(command "_.-LAYER" "_OFF" "*" "_Y")
(foreach VAL LAYLST (command "_ON" VAL))
(command "")
(foreach VAL LAYLST (command "_ON" VAL))
(command "")
I've also found this to check whether a layer exists (NEWLAYER in this example):
(setq flag (tblsearch "LAYER" "NEWLAYER"))
And this for the string length:
strlen
Thanks,
Ken





RE: Lisp-Adding to a Selection Set
(setq *acad-object* nil) ; Initialize global variable
(setq *active-document* nil) ; Initialize global variable
(defun pp_GetActiveDocument ()
(cond (*active-document*) ; Return the cached object
(T
(setq *active-document* (vla-Get-ActiveDocument (pp_GetAcadObject)))
)
)
)
(defun pp_GetAcadObject ()
(cond (*acad-object*) ; Return the cached object
(T
(setq *acad-object* (vlax-Get-Acad-Object))
)
)
)
(defun pp_UnlockAllLayers (/ EA_LYR)
(vl-catch-all-error-p
(vlax-for EA_LYR (vla-get-Layers (pp_GetActiveDocument))
(vla-put-lock EA_LYR :vlax-false)
)
)
)
http://mechcad-insider.blogspot.com/
"The fear of the Lord is the beginning of wisdom"
RE: Lisp-Adding to a Selection Set
(Defun C:L1 ()
(Command("Layer" "Freeze" "*" "Thaw" "1*")
(princ)
)
RE: Lisp-Adding to a Selection Set
Thanks,
Ken