Jump to content

Recommended Posts

Posted

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.

Posted

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)))

Posted

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

Posted

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))

Posted

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))

Posted

Thank You So Much Mircea.

Now its clear.

 

Regards

Aaryan

Posted

Glad to hear that, Aaryan. You're welcome!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...