Changes entities to layer 0, c
Looking for lisp to do the following:Changes entities to layer 0, color GREEN and nothing else.
any help?
Thanks
jim OK, change simple entities green, move them to layer zero and nothing else.
(Requires preselect, so PICKFIRST must be on)
(defun c:lzg (/ gsel sslen n en el)(setq gsel (ssget "I"))(setq sslen (sslength gsel))(setq n 0)(if gsel(while (< n sslen) (setq en (ssname gsel n)) (setq el (entget en)) (setq el (subst (cons 62 3) (assoc 62 el) el)) (setq el (subst (cons 8 "0") (assoc 8 el) el)) (entmod el) (setq n (+ n 1)) ))(setq gsel nil)(princ)) Yikes!I hope I never have to work on your drawings....
Not that I doubt the lisp-capability, but why not do a Ctrl+A (to select everything) then change the layer and color in the Properties palette?
But I agree with above, this sounds like you'll just mess up your drawing. IF you care to let us know what the purpose is, there might be better ways to do it. CALCAD,
You will need to allow for those ent's without a DXF 62 code
(defun c:doit (/ i ss ent eLst) (if (setq i -1 ss (ssget "_:L")) (while (setq ent (ssname ss (setq i (1+ i)))) (setq eLst (entget ent)) (setq eLst (subst '(8 . "0") (assoc 8 eLst) eLst)) (entmod (if (assoc 62 eLst) (subst '(62 . 3) (assoc 62 eLst) eLst) (append eLst '((62 . 3))))))) (princ)) Lee,
You're right, of course, about handling entities without the 62 dxf code (the BYLAYER entities, I guess - are there others?)
Thanks for that. But I can't get your code to work on my old Intellicad. I looked up the "_:L" option and I see that one would
want to avoid selecting from locked layers, but does (ssget "_:L") select anything else? I have to substitute with (ssget "I")
to make it work.
Hmmm.. it works fine on ACAD2010, so it could just be an issue in Intellicad with the "_:L", although I've never had that issue reported before.
As for the DXF 62 code, I would normally use VL to change color, as the property is always available, and its a quick one-liner, but, when dealing with DXF codes, I would always check, as BYLAYER ents won't have it. An alternative to "_:L" would be this I suppose:
(defun c:doit (/ lock tdef i ss ent eLst) (setq lock "")(while (setq tdef (tblnext "LAYER" (not tdef))) (if (= 4 (logand 4 (cdr (assoc 70 tdef)))) (setq lock (strcat lock (cdr (assoc 2 tdef)) ",")))) (if (setq i -1 ss (ssget (list '(-4 . "")))) (while (setq ent (ssname ss (setq i (1+ i)))) (setq eLst (entget ent)) (setq eLst (subst '(8 . "0") (assoc 8 eLst) eLst)) (entmod (if (assoc 62 eLst) (subst '(62 . 3) (assoc 62 eLst) eLst) (append eLst '((62 . 3))))))) (princ)) What about heavy polylines sequential entities?Attributes?BLOCK table entities?
I actually do this a good bit.Merge only the elements of an architect's backgound that I need onto a single layer ( "1D-ARCH" I call it ).I retain the entity original color though, even if bylayer ( I make it the color of the original layer )
-David And it sounded like such a simple question. Damn.
页:
[1]
2