Jump to content

Changes entities to layer 0, color GREEN lisp


Recommended Posts

Posted

Looking for lisp to do the following:

Changes entities to layer 0, color GREEN and nothing else.

 

any help?

 

Thanks

jim

Posted

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

Posted

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

Posted
Looking for lisp to do the following:

Changes entities to layer 0, color GREEN and nothing else.

 

any help?

 

Thanks

jim

 

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.

Posted

CALCAD,

 

You will need to allow for those ent's without a DXF 62 code :thumbsup:

 

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

Posted

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.

Posted
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. :)

Posted

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 . "<NOT")
                                (cons 8 (substr lock 1 (1- (strlen lock))))
                                '(-4 . "NOT>"))))
   
   (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))

Posted

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

Posted

Hey thanks a lot guys, yeah I hate working on these drawings too, but I get paid to do what they want me to do, single layer with tiff image, two colors, one for drawing one for errors they think that needs to be changed......

If it wasn't for the low pay I'd be doing something else.....

 

some people are brighter then others, its hard for them to shine bright when their brightness is like a single burning candle during the day.

 

enough said, and now you have a glimps of what I have to deal with.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...