Engineer_Yasser Posted September 28, 2023 Posted September 28, 2023 Please , How to Select All Polylines in the drawing except from Frozen and Locked and OFF layers ? Quote
BIGAL Posted September 28, 2023 Posted September 28, 2023 (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 September 28, 2023 by BIGAL Quote
Engineer_Yasser Posted September 28, 2023 Author Posted September 28, 2023 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 Quote
lastknownuser Posted September 28, 2023 Posted September 28, 2023 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) ) 1 Quote
Engineer_Yasser Posted September 28, 2023 Author Posted September 28, 2023 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 Quote
Emmanuel Delay Posted September 28, 2023 Posted September 28, 2023 (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 September 28, 2023 by Emmanuel Delay 3 Quote
Engineer_Yasser Posted October 4, 2023 Author Posted October 4, 2023 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. 1 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.