Lisp to isolate layers that have multiple hatches

Lisp to isolate layers that have multiple hatches

Anonymous
Not applicable
1,010 Views
6 Replies
Message 1 of 7

Lisp to isolate layers that have multiple hatches

Anonymous
Not applicable

Hello,

 

As the title suggests, any idea? 

0 Likes
Accepted solutions (1)
1,011 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

Perhaps like this?

 

(defun c:LayIsoWHatches ( / def lay sel lst)

  (while (setq def (tblnext "LAYER" (null def)))
    (and (setq lay (cdr (assoc 2 def)))
         (setq sel (ssget "_X" (list '(0 . "HATCH") (cons 8 lay))))
         (> (sslength sel) 1)
         (setq lst (cons lay lst))))

  (if lst
    (progn
      (command "_.-LAYER"
               "_Off" "*" "_Yes")
      (foreach l lst
        (command "_On" l))
      (command "_Set" (car lst) "")))
  (princ (strcat "\n" (itoa (length lst)) " layers isolated."))
  (princ)
)
Message 3 of 7

Anonymous
Not applicable

Hello again,

 

Is possible to make this to isolate layers that have multiple polylines?

 

Thanks

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

Just replace "HATCH" with "LWPOLYLINE".

Message 5 of 7

Anonymous
Not applicable

Worked, how to make it isolate layers without any polylines?

Thank you

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant

(setq sel (ssget "_X" (list '(0 . "HATCH") (cons 8 lay))))
(> (sslength sel) 1)

 

; ->

 

(not (ssget "_X" (list '(0 . "LWPOLYLINE") (cons 8 lay))))

Message 7 of 7

Anonymous
Not applicable

Thank you a lot!

0 Likes