Jump to content
GermanLarraguibel

Change especific True color to especific ASC color by LISP

Recommended Posts

GermanLarraguibel

Hi guys, I have a lot of drawing imported from another design software but he brings me true colors objects and what i need is change this colors to normal colors:

 

 

From 0,128,0 to 94 (green)

From 255,255,255 to 255 (White)

From 100,60,30 to 27 (brown)

From 31,26,23 to 250 (black)

 

 

I need a lisp to make this changes automatically...

 

 

Thanks,

Share this post


Link to post
Share on other sites
Stefan BMR

Any object set to TrueColor holds the corresponding ACI, so the only thing you have to do is to remove 420 dxf code (that holds truecolor).

;Change all TrueColor to AutoCAD Color Index
(defun c:all_to_aci ( / remove420 la e)
 (defun remove420 (entity_list)
   (entmod (vl-remove (assoc 420 entity_list) entity_list))
   )
 (while
   (setq la (tblnext "layer" (not la)))
   (remove420 (entget (tblobjname "layer" (cdr (assoc 2 la)))))
   )
 (while (setq e (if e (entnext e) (entnext)))
   (remove420 (entget e))
 )
 (princ)
)

 

PS1: I didn't test it on blocks, nested blocks or Xrefs.

PS2: Something is wrong with your transformation: 0,128,0 is 96 and 100,60,30 is 39

Share this post


Link to post
Share on other sites
GermanLarraguibel

Thanks Stefan,

 

The lisp Works Fine !

 

About the corresponding you are right.

I just wanna change the colors to 94 and 27 because i have to obeying my CTB plot list.

 

My archive contains only hatches ... no lines, no solidis, no blocks !

 

Thanks a lot !

Share this post


Link to post
Share on other sites
handasa

can you modify it please to be applied to nested blocks (block sub entities)

Share this post


Link to post
Share on other sites
Stefan BMR
can you modify it please to be applied to nested blocks (block sub entities)

Sure... ALL the objects, right?

(defun c:all_to_aci ( / remove420 la en)
 (defun remove420 (entity_list)
   (vl-catch-all-apply '(lambda nil (entmod (vl-remove (assoc 420 entity_list) entity_list))))
   )
 (while
   (setq la (tblnext "layer" (not la)))
   (remove420 (entget (tblobjname "layer" (cdr (assoc 2 la)))))
   )
 (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
   (if
     (not (eq (vla-get-isxref block) :vlax-true))
     (vlax-for en block
       (remove420 (entget (vlax-vla-object->ename en)))
       )
     )
   )
 (princ)
)

Share this post


Link to post
Share on other sites
handasa

work like a charm ... many thanks

mr.Stefan BMR

a gret job

thanks again

Share this post


Link to post
Share on other sites
Stefan BMR

You are welcome handasa. Thanks for mentioning the solution on TheSwamp too.

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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