djguinan 11 Posted January 6, 2012 Does anyone have a lisp routine to globally convert entities from index colour to rgb(true colour)? I found a routine that does it the opposite way around. Quote Share this post Link to post Share on other sites
Tharwat 166 Posted January 6, 2012 Welcome to the forum What do you mean by the rgb colour ? Does it mean ByLayer ? Quote Share this post Link to post Share on other sites
djguinan 11 Posted January 6, 2012 Thanks for the Welcome Tharwat:) I have solid hatch entities in a drawing that I want to be True Colour rather then Index Colour. When in the Select Colour Dialoge box its the middle tab. Quote Share this post Link to post Share on other sites
Tharwat 166 Posted January 6, 2012 Hope my post in the following thread would help you with it .. http://www.cadtutor.net/forum/showthread.php?65047-color-change-in-all-layer-from-selected-area&p=444444&viewfull=1#post444444 Quote Share this post Link to post Share on other sites
djguinan 11 Posted January 6, 2012 No Sorry, if it helps this lisp is the opposite of what I want to do. rgb2aci.lsp 1 Quote Share this post Link to post Share on other sites
djguinan 11 Posted January 6, 2012 Lee Mac I only spotted your reply as I subbmitted a reply to Tharwat. That is exactly what I'm looking for, thanks very much:) Quote Share this post Link to post Share on other sites
Lee Mac 453 Posted January 6, 2012 (edited) Try this: ;; All to RGB - Lee Mac - www.lee-mac.com ;; Converts the ACI colours of all entities to the RGB TrueColor equivalent (defun c:AlltoRGB ( / accm c e i s ) (if (and (setq s (ssget "_:L")) (setq accm (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AutoCAD.AcCmColor." (substr (getvar 'ACADVER) 1 2)) ) ) ) (progn (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i))))) (if (setq c (cdr (assoc 62 e))) (progn (vla-put-colorindex accm c) (entmod (append e (list (cons 420 (LM:RGB->True (vla-get-red accm) (vla-get-green accm) (vla-get-blue accm) ) ) ) ) ) ) ) ) (vlax-release-object accm) ) ) (princ) ) ;; RGB -> True - Lee Mac 2011 ;; Args: r,g,b - Red,Green,Blue values (defun LM:RGB->True ( r g b ) (+ (lsh (fix r) 16) (lsh (fix g) (fix b) ) ) (vl-load-com) (princ) It will change the colour of selected entities from the ACI colour to the RGB True Colour equivalent. Note that it will change only those entities whose colour is not set to ByLayer (though these may be included if necessary by changing the respective layer colours). More Colour Conversion functions. Edited July 3, 2019 by Lee Mac Quote Share this post Link to post Share on other sites
Lee Mac 453 Posted January 6, 2012 Lee Mac I only spotted your reply as I subbmitted a reply to Tharwat. That is exactly what I'm looking for, thanks very much:) I modified it slightly and re-posted, please use the updated version above ^^ Thanks - glad it works for you. Quote Share this post Link to post Share on other sites
djguinan 11 Posted January 6, 2012 Thanks guys you've saved me alot of time. I'm a first time user of this site and I have to say I'm very impressed with the quick responses:) Happy New Year Quote Share this post Link to post Share on other sites
Lee Mac 453 Posted January 6, 2012 Thanks guys you've saved me alot of time. I'm a first time user of this site and I have to say I'm very impressed with the quick responses:)Happy New Year You're very welcome djguinan, hope to see you back soon Quote Share this post Link to post Share on other sites
rhgrafix 10 Posted February 25, 2018 Try this: [color=GREEN];; All to RGB - Lee Mac - www.lee-mac.com[/color]etc. I found something strange while using this, I tested it in a color wheel dwg with index color swatches 40 through 49; colors 40(255,191,0) & 41(255,223,127) were correct; the other 8 were wrong; 42 became (204,153,0), should be (165,124,0); 43 became (204,178,102), should be (165,145,82); etc. Another interesting thing, the chart of colors on this site is different than both the results of your .lsp and what my tests on Autocad 2018 are: http://sub-atomic.com/~moses/acadcolors.html . Could it be that Autodesk did not space their color index evenly so a somewhat simple algorithm does not return values that line up with their index? BTW, it's a great macro!Thanks,R.L. Hamm Quote Share this post Link to post Share on other sites
Roy_043 96 Posted February 25, 2018 @rhgrafix: I am afraid you are using information that is obsolete. You can verify the RGB values of ACI colors by means of a screenshot. Quote Share this post Link to post Share on other sites
tranhongquang 0 Posted January 20 On 1/6/2012 at 11:42 PM, djguinan said: No Sorry, if it helps this lisp is the opposite of what I want to do. rgb2aci.lsp 2.36 kB · 140 downloads it very good, thank you so much. Quote Share this post Link to post Share on other sites