Jump to content

Select All Polylines in the drawing except from Frozen and Locked and OFF layers ?


Recommended Posts

Posted

 

Please , How to Select All Polylines in the drawing except from Frozen and Locked and OFF layers ? 😰

Posted (edited)

Using ssget with layer off or frozen are as a rule not found, you can add a ssget filter is (62 . 7) locked. 

 

Have a look at help re ssget and using not.

Not tested

(ssget '((0 . "LWPOLYLINE") (-4 . "<>") (62 . 7)))

 

Edited by BIGAL
Posted
12 minutes ago, BIGAL said:

Using ssget with layer off or frozen are as a rule not found, you can add a ssget filter is (62 . 7) locked. 

 

Have a look at help re ssget and using not.

Not tested

(ssget '((0 . "LWPOLYLINE") (-4 . "<>") (62 . 7)))

 

Thanks for help .. but i need to exclude all frozen and Locked and OFF layers 

Posted
2 hours ago, Engineer_Yasser said:

 

Please , How to Select All Polylines in the drawing except from Frozen and Locked and OFF layers ? 😰


https://forums.augi.com/showthread.php?153671-SSget-X-except-Frozen-Locked-or-Off-layers

And a little bit of editing:
 

(defun c:demo (/ a ex)
  (setq ex nil)
  (while (setq a (tblnext "LAYER" (null a)))
    (if	(and (or (> (cdr (assoc 70 a)) 0)
		 (minusp (cdr (assoc 62 a)))
	     )
	     (not (wcmatch (cdr (assoc 2 a)) "*|*"))
	)
      (setq ex (cons (strcat "," (cdr (assoc 2 a))) ex))
    )
  )
  (setq	ss (ssget "_X"
		  (append
		    (list (cons 0 "LWPOLYLINE,POLYLINE")
			  (cons 410 (getvar 'ctab))
		    )
		    (if	ex
		      (list
			'(-4 . "<NOT")
			(cons 8 (strcat (apply 'strcat ex)))
			'(-4 . "NOT>")
		      )
		      '(8 . "*")
		    )
		  )
	   )
  )
  (princ)
)

 

  • Thanks 1
Posted
39 minutes ago, lastknownuser said:


https://forums.augi.com/showthread.php?153671-SSget-X-except-Frozen-Locked-or-Off-layers

And a little bit of editing:
 

(defun c:demo (/ a ex)
  (setq ex nil)
  (while (setq a (tblnext "LAYER" (null a)))
    (if	(and (or (> (cdr (assoc 70 a)) 0)
		 (minusp (cdr (assoc 62 a)))
	     )
	     (not (wcmatch (cdr (assoc 2 a)) "*|*"))
	)
      (setq ex (cons (strcat "," (cdr (assoc 2 a))) ex))
    )
  )
  (setq	ss (ssget "_X"
		  (append
		    (list (cons 0 "LWPOLYLINE,POLYLINE")
			  (cons 410 (getvar 'ctab))
		    )
		    (if	ex
		      (list
			'(-4 . "<NOT")
			(cons 8 (strcat (apply 'strcat ex)))
			'(-4 . "NOT>")
		      )
		      '(8 . "*")
		    )
		  )
	   )
  )
  (princ)
)

 

 

 

Thanks   😍😍   Super Saver

Posted (edited)

You don't need another script.

But here's one anyway.

Maybe it helps someone who needs parts of this code some day

 

command Test2

 

(vl-load-com)

;; if no parameter if given, then a list of all layers is given.
;; if a layer is given, the function returns True when the layer is "On", "not frozen" and "not locked".  Else nil is returned
(defun get_layers (lay / lyr table ret) 
	(setq ret T)
	(vlax-for lyr
		(vla-get-layers
			(vla-get-activedocument
				(vlax-get-acad-object)
			)
		)
		(if (= (vla-get-name lyr) lay)
			(if 
				(and
					(= :vlax-true (vla-get-layeron lyr))
					(= :vlax-false (vla-get-freeze lyr))
					(= :vlax-false (vla-get-lock lyr))
				)
				(setq ret T)
				(setq ret nil)
			)
		)
		(setq table (cons (vla-get-name lyr) table))
	)
	(if lay
		ret
		table
	)
)

(defun c:test ( / )
	(get_layers nil)
)

(defun c:test2 ( / ss ss2 i)
	(setq ss (ssget "_X" (list (cons 0 "*POLYLINE"))))
	
	(setq i 0)
	(setq ss2 (ssadd))
	(repeat (sslength ss)
		(setq obj (ssname ss i))
		(if (get_layers (cdr (assoc 8 (entget obj))))  ;; will skip things of layers that are off/frozen/locked
			(setq ss2 (ssadd (ssname ss i) ss2))		
		)
		(setq i (+ i 1))
	)
	(sssetfirst nil ss2)
		
	(princ)
)

 

Edited by Emmanuel Delay
  • Like 3
Posted
On 9/28/2023 at 4:05 PM, Emmanuel Delay said:

You don't need another script.

But here's one anyway.

Maybe it helps someone who needs parts of this code some day

 

command Test2

 

(vl-load-com)

;; if no parameter if given, then a list of all layers is given.
;; if a layer is given, the function returns True when the layer is "On", "not frozen" and "not locked".  Else nil is returned
(defun get_layers (lay / lyr table ret) 
	(setq ret T)
	(vlax-for lyr
		(vla-get-layers
			(vla-get-activedocument
				(vlax-get-acad-object)
			)
		)
		(if (= (vla-get-name lyr) lay)
			(if 
				(and
					(= :vlax-true (vla-get-layeron lyr))
					(= :vlax-false (vla-get-freeze lyr))
					(= :vlax-false (vla-get-lock lyr))
				)
				(setq ret T)
				(setq ret nil)
			)
		)
		(setq table (cons (vla-get-name lyr) table))
	)
	(if lay
		ret
		table
	)
)

(defun c:test ( / )
	(get_layers nil)
)

(defun c:test2 ( / ss ss2 i)
	(setq ss (ssget "_X" (list (cons 0 "*POLYLINE"))))
	
	(setq i 0)
	(setq ss2 (ssadd))
	(repeat (sslength ss)
		(setq obj (ssname ss i))
		(if (get_layers (cdr (assoc 8 (entget obj))))  ;; will skip things of layers that are off/frozen/locked
			(setq ss2 (ssadd (ssname ss i) ss2))		
		)
		(setq i (+ i 1))
	)
	(sssetfirst nil ss2)
		
	(princ)
)

 

 

 

 First of all Thanks for posting another code 🌹

 

The 1st code stopped working today suddenly without any reason .. I don't know why !!

 

 But your code is working like a charm ... Thank you very much for your help.   😍😍

  • Like 1

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