Need help to creating a list of layer (LAYER1,LAYER2,LAYER3,…….) from a selection of entity
Hi
This is my first post, my name is Lorenzo I’m living in northern Quebec in Canada. I’m a Mechanical designer & draftsmen for the last 18 years & recently got a new job where they only use 2d & since I use 3d Inventor for the last 10 years I had to take my old routine from the mothballs & put them back to work.
My problems is that i do not find my autolisp class note from the 90 & now I need to built a new Layer manipulation routine from scratch & I just don’t remember how.! Well I remember many parts but not enough so I pick-up some lines from existing routine
The proposed routine will go like this
1-Selection of objects & extraction of layer name of each object with something like:
(setq A (cdr (assoc 8 (entget (car (entsel "\nPick entity to keep layer on: "))))))
2-Building a list of the layer name from previous selection
That where I jam!
4-Off or freeze of all layer with something like
(command "_-layer" "_off" "*" "" "")
5-On or thaw of the list of the previously selected item
(command "_-layer" "_on" "???????list generated with item 2???????" ""))
My guess that I should use ssget instead of enget but I’m not sure & I don’t remember how to use it anyway!
Any help would be appreciated
Thanks
Lorenzo Di Marco
Re: Need help to creating a list of layer (LAYER1,LAYER2,LAYER3,…….) from a selection of entity
For fun...
Code:
(defun c:FOO ( / ss i e layer layers)
(vl-load-com)
(if (setq ss (ssget))
(progn
(setq i -1)
(while (and (setq e (ssname ss (setq i (1+ i))))
(not (vl-position
(setq layer (cdr (assoc 8 (entget e))))
layers)))
(setq layers (cons layer layers)))
(command "._-layer"
"freeze"
"*"
"thaw"
(strcat
(getvar 'clayer)
","
(vl-string-right-trim
","
(apply 'strcat
(mapcar '(lambda (x) (strcat x ",")) layers))))
"")))
(princ))
Re: Need help to creating a list of layer (LAYER1,LAYER2,LAYER3,…….) from a selection of entity
Also, for simplicity...
Code:
(defun c:FOO2 ()
(command "layiso" "settings" "off" "off"))
Re: Need help to creating a list of layer (LAYER1,LAYER2,LAYER3,…….) from a selection of entity
Hi .
I am not sure if I got you well , so here is one try to put a list of selection set's layers off .
Code:
(defun c:Test (/ ss i sn lst)
(vl-load-com)
;;; Tharwat 01. May. 2012 ;;;
(cond ((not acdoc)
(setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
)
)
(if (setq ss (ssget))
(repeat (setq i (sslength ss))
(setq sn (ssname ss (setq i (1- i))))
(if (not (member (cdr (assoc 8 (entget sn))) lst))
(progn
(setq lst (cons (cdr (assoc 8 (entget sn))) lst))
(vla-put-layeron
(vla-item (vla-get-layers
acdoc
)
(cdr (assoc 8 (entget sn)))
)
:vlax-false
)
)
)
)
(princ)
)
(princ)
)
Re: Need help to creating a list of layer (LAYER1,LAYER2,LAYER3,…….) from a selection of entity
Quote:
Originally Posted by
Tharwat
I am not sure if I got you well , so here is one try to put a list of selection set's layers off .
Tharwat, I believe the OP is wanting to freeze all layers except for those in the selection set (similar to LAYISO command).
Re: Need help to creating a list of layer (LAYER1,LAYER2,LAYER3,…….) from a selection of entity
Quote:
Originally Posted by
RenderMan
Tharwat, I believe the OP is wanting to freeze all layers except for those in the selection set (similar to LAYISO command).
Thanks Renderman .
Here is my try again .....
Code:
(defun c:Test (/ ss i sn lst l)
(vl-load-com)
;;; Tharwat 01. May. 2012 ;;;
(cond ((not acdoc)
(setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
)
)
(if (setq ss (ssget))
(progn
(repeat (setq i (sslength ss))
(setq sn (ssname ss (setq i (1- i))))
(if (not (member (cdr (assoc 8 (entget sn))) lst))
(setq lst (cons (cdr (assoc 8 (entget sn))) lst))
)
)
(while (setq l (tblnext "LAYER" (null l)))
(if (and (not (member (cdr (assoc 2 l)) lst))
(not (eq (getvar 'clayer) (cdr (assoc 2 l))))
)
(vla-put-freeze
(vla-item (vla-get-layers acdoc) (cdr (assoc 2 l)))
:vlax-true
)
)
)
)
(princ)
)
(princ)
)
Re: Need help to creating a list of layer (LAYER1,LAYER2,LAYER3,…….) from a selection of entity
Tharwat,
Rather than iterating the SelectionSet, then the Layer Table, then the Layers Collection (vla), why not simply iterate the SelectionSet, then the Layers Collection?
Again, for the stated task, the LayIso Command is all that is needed, IMO.