Need Help: Please modify the code to change lineweight for non Xref layers only

Need Help: Please modify the code to change lineweight for non Xref layers only

le-tan-phuc
Enthusiast Enthusiast
421 Views
4 Replies
Message 1 of 5

Need Help: Please modify the code to change lineweight for non Xref layers only

le-tan-phuc
Enthusiast
Enthusiast


I got this lisp from the internet but it change all layers included Xref layers
Someone can help me to exclude Xref layers please. Sorry for my bad English.
;;Change All layer in Default lineweight to 0.05 lineweight
(defun c:C005 ()
((lambda (/ n l w)
(while (setq n (cdr (assoc 2 (tblnext "LAYER" (not n)))))
(setq w (cdr (assoc 370 (setq l (entget (tblobjname "LAYER" n))))))
(if (= w -3)
(entmod (subst '(370 . 5) (cons 370 w) l))))))
(princ)
)

0 Likes
Accepted solutions (2)
422 Views
4 Replies
Replies (4)
Message 2 of 5

komondormrex
Mentor
Mentor
Accepted solution
(defun c:C005 ()
	(
		(lambda (/ n l w)
			(while (setq n (cdr (assoc 2 (tblnext "LAYER" (not n)))))
				(if (not (wcmatch n "*|*"))
					(progn
						(setq w (cdr (assoc 370 (setq l (entget (tblobjname "LAYER" n))))))
						(if (= w -3)
						(entmod (subst '(370 . 5) (cons 370 w) l)))
					)
				)
			)
		)
	)
	(princ)
)
0 Likes
Message 3 of 5

le-tan-phuc
Enthusiast
Enthusiast

it works perfectly
Thank you so much Komondormrex !

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

Another way, using a different determination of whether a Layer is Xref-dependent [the DXF 70 value containing the 16 bit, rather than the | in the Layer name]:

(defun C:C005 (/ lname ldata); All non-Xref Layers of default LW to 0.05 LW
  (while (setq lname (cdr (assoc 2 (tblnext "LAYER" (not lname)))))
    (setq ldata (entget (tblobjname "LAYER" lname)))
    (if (and (member '(370 . -3) ldata) (= (logand (cdr (assoc 70 ldata)) 16) 0))
      (entmod (subst '(370 . 5) (assoc 370 ldata) ldata))
    ); if
  ); while
  (prin1)
)

 

Kent Cooper, AIA
0 Likes
Message 5 of 5

le-tan-phuc
Enthusiast
Enthusiast

this code work great also
Thank you for sharing this knowledge Mr Kent1Cooper.

0 Likes