kingisland99762 发表于 2022-7-6 11:48:02

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

CALCAD 发表于 2022-7-6 11:54:32

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

ronjonp 发表于 2022-7-6 12:05:17

Yikes!I hope I never have to work on your drawings....

Tiger 发表于 2022-7-6 12:09:19

 
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.

Lee Mac 发表于 2022-7-6 12:15:13

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

CALCAD 发表于 2022-7-6 12:18:58

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.

Lee Mac 发表于 2022-7-6 12:29:41

 
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.

Lee Mac 发表于 2022-7-6 12:33:00

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

David Bethel 发表于 2022-7-6 12:36:23

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

CALCAD 发表于 2022-7-6 12:47:08

And it sounded like such a simple question. Damn.
页: [1] 2
查看完整版本: Changes entities to layer 0, c