본문 바로가기
autocad

To change true color to ACI(AutoCAD Color Index) of Layers

by kmlab 2024. 8. 29.

 

 

Routine to change RGB colors to ACI/Index 255 colors (and the opposite)

  Hello Friends   I am looking for a routine to change - on ALL objects of the current drawing (entire DWG) OR - on ONLY on a classic AutoCAD selection   *** Routine: TO255COLORS Brownse all entities and all blocks and sub-blocks and sub-entities (of th

forums.autodesk.com

(defun C:LAYERCOLORTOINDEX (/ acad doc color2 n1 color1 method1 colorindex)
  ;;; By 3wood 31/03/2016, Change truecolor layer colors to index colors 
  (setq acad (vlax-get-acad-object)
doc (vla-get-activedocument acad)
color2 (vla-GetInterfaceObject acad (strcat "AutoCAD.AcCmColor." (substr (vlax-product-key) 28 2)))
)
  (vla-startundomark doc)
  (vlax-for n1 (vla-get-layers doc)
    (setq color1 (vla-get-truecolor n1)
  method1 (vla-get-colormethod color1)
  colorindex (vla-get-colorindex color1)
  )
    (if (/= method1 195)
      (progn
(vla-put-colorindex color2 colorindex)
(vla-put-truecolor n1 color2)
      )
      )
    )
  (vla-endundomark doc)
  (princ)
  )

반응형