aaryan Posted July 17, 2012 Posted July 17, 2012 Hi All, I made a routine which has a selection set of different objects with different layers. Please help me know how can i step through the selection set and pick an object from a specific layer. Regards Aaryan. Quote
MSasu Posted July 17, 2012 Posted July 17, 2012 You should look to SSNAME and ENTGET functions; the layer is stored under DXF code 8. Alternatively, whe create the selection set may filter only entities from a specific layer: (ssget "_X" (list (cons 8 MyLayer))) Quote
aaryan Posted July 17, 2012 Author Posted July 17, 2012 Thank You Mircea But i want to select an object from a selection set and save it as a variable to use further. I cannot use ssget "X" function as i have to select multiple objects with different layers. What I did so far is as follows. (defun c:test(/ Objectlist) (prompt "\nSelect Objects to generate") (setq sel1 (ssget '((0 . "POLYLINE,LWPOLYLINE") (8 . "Xpro,Fpro,Cpro")))) (setq cntr 0 Objectlist '()) (repeat (sslength sel1) (setq entityname (ssname sel1 cntr) Objectlist (append (list entityname) Objectlist)) (setq cntr (1+ cntr))) (setq check (mapcar '(lambda (a) (= (cdr (assoc 8 (entget a))) "Fpro")) Objectlist)) (princ)) I only need the check variable to save the object in the layer Fpro Please do the needful Regards Aaryan Quote
MSasu Posted July 17, 2012 Posted July 17, 2012 You may create the list when parse the selection set - just retain to it only items from said layer: (defun c:test( / Objectlist sel1 cntr check ) (prompt "\nSelect Objects to generate") (setq sel1 (ssget '((0 . "POLYLINE,LWPOLYLINE") (8 . "Xpro,Fpro,Cpro")))) (setq cntr 0 Objectlist '() [color=red] check '()[/color]) (repeat (sslength sel1) (setq entityname (ssname sel1 cntr)) [color=red] (if (= (strcase (cdr (assoc 8 (entget entityname)))) "FPRO")[/color] [color=red] (setq check (append (list entityname) check))[/color] [color=red] )[/color] [color=black] (setq Objectlist (append (list entityname) Objectlist))[/color] (setq cntr (1+ cntr))) (princ)) Quote
MSasu Posted July 17, 2012 Posted July 17, 2012 If want to process directly from main list: (setq check (vl-remove-if-not '(lambda(x) (= (strcase (cdr (assoc 8 (entget x)))) "FPRO")) Objectlist)) or: (setq check (vl-remove-if '(lambda(x) (/= (strcase (cdr (assoc 8 (entget x)))) "FPRO")) Objectlist)) Quote
aaryan Posted July 17, 2012 Author Posted July 17, 2012 Thank You So Much Mircea. Now its clear. Regards Aaryan Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.