Jump to content

Recommended Posts

Posted

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,

Posted

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

Posted

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 !

  • 1 year later...
Posted

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

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

Posted

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

  • 7 years later...
Posted

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

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