Jump to content

Change especific True color to especific ASC color by LISP


GermanLarraguibel

Recommended Posts

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,

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

  • 1 year later...
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)
)

Link to comment
Share on other sites

  • 7 years later...

Can anyone create a lisp routine to change autocad defined color, say red (10) to RGB 253,155,155 which will give me the color and brightness I need.

Have several other colors but once I get the syntax I can do the rest. Thanks

Link to comment
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
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...