Lisp to delete specific color .

Lisp to delete specific color .

Anonymous
Not applicable
2,135 Views
7 Replies
Message 1 of 8

Lisp to delete specific color .

Anonymous
Not applicable

Can someone help me do the code. I want to delete all color index 210 with different layer. Thanks in advance.

 

0 Likes
2,136 Views
7 Replies
  • Lisp
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Can someone help me do the code. I want to delete all color index 210 with different layer. ....


Do you mean you want to delete all objects  that have color 210 assigned to them?  If so, do you want to delete only those with color 210 as a color override, or also objects of ByLayer  color on Layers whose color is 210?

 

Or do you mean something else?  [For example, maybe to not delete objects, but to not have any with color 210 by changing them to a different color?]

 

Have you started to write some code that we can help you with?

Kent Cooper, AIA
0 Likes
Message 3 of 8

Anonymous
Not applicable

Yes. I want to delete only those with color 210 as a color override.

0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Yes. I want to delete only those with color 210 as a color override.


That would involve an (ssget) function with the "_X" selection mode to search the entire drawing without User selection, and a filter list limiting what it finds to things with that color -- 62 is the DXF code for a color override entry.  It could then either use an ERASE command on what it finds if they're all in the current space, or it could step through the selection and use (entdel) to remove each object.

 

Since you said "help me do the code," is that enough to get you started?

Kent Cooper, AIA
Message 5 of 8

pbejse
Mentor
Mentor

@Anonymous wrote:

Yes. I want to delete only those with color 210 as a color override.


So basically Goodbye 210.

 

(defun c:Goodbye210 ( / Adoc)
  (vlax-for blk	(Vla-get-Blocks
		  (setq adoc (vla-get-ActiveDocument (vlax-get-acad-object)))
		)
    (if	(eq :vlax-false (vla-get-isXref blk))
      (vlax-for	h blk
	(if (and
	      (vlax-write-enabled-p h)
	      (vlax-property-available-p h "Color")
	      (= 210 (vlax-get h 'Color))
	    )
	  (Vla-delete h)
	)
      )
    )
  )
  (vla-regen adoc acAllViewports)
(princ)
)

 

To include objects inside blocks.

HTH

Message 6 of 8

CodeDing
Advisor
Advisor

@Kent1Cooper ,

 

😂😂 

 

I often find myself in both positions. Yours and @pbejse ... They always say "i want help" (but they clearly want it done for them).. So sometimes I try to hold them accountable, then other times I decide I can use the practice and just create the commnand/function anyways.. We just can't win either way.

0 Likes
Message 7 of 8

pbejse
Mentor
Mentor

@CodeDing wrote:

I often find myself in both positions. Yours and @pbejse ... They always say "i want help" (but they clearly want it done for them).. So sometimes I try to hold them accountable, then other times I decide I can use the practice and just create the commnand/function anyways.. We just can't win either way.


I am at that place now @CodeDing  Today is the only time i had the chance to visit the forum and read the post, totally swamp with work these past few days. I needed a break 😁.

 

 

 

Message 8 of 8

andkal
Collaborator
Collaborator

Maybe you will find this tool useful  -> available at autodesk app sotre >click<.
Plain fas file available >here<.

Its a kind of "quick select" but appends selections of choosen colors (or type or layer).
After filtering selection by color you can just delete them with DELETE command.


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes