djguinan Posted January 6, 2012 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
Tharwat Posted January 6, 2012 Posted January 6, 2012 Welcome to the forum What do you mean by the rgb colour ? Does it mean ByLayer ? Quote
djguinan Posted January 6, 2012 Author 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
Tharwat Posted January 6, 2012 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
djguinan Posted January 6, 2012 Author Posted January 6, 2012 No Sorry, if it helps this lisp is the opposite of what I want to do. rgb2aci.lsp 1 Quote
djguinan Posted January 6, 2012 Author 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
Lee Mac Posted January 6, 2012 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) 8) (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 April 5, 2021 by Lee Mac 1 Quote
Lee Mac Posted January 6, 2012 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
djguinan Posted January 6, 2012 Author 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
Lee Mac Posted January 6, 2012 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
rhgrafix Posted February 25, 2018 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
Roy_043 Posted February 25, 2018 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
tranhongquang Posted January 20, 2021 Posted January 20, 2021 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
harinezumi Posted April 5, 2021 Posted April 5, 2021 On 1/6/2012 at 5:45 PM, Lee Mac said: Try this: […] 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. Hi Lee Mac, Thank you for your code. I try it in acad 2021 but I get the error: Quote Command: APPLOAD allToRBG.lsp successfully loaded. Command: ; error: malformed list on input when loading then Quote Command: ALLTORGB Select objects: Specify opposite corner: 268 found Select objects: ; error: no function definition: LM:RGB->TRUE when running. Can you please help? Thank you Quote
Lee Mac Posted April 5, 2021 Posted April 5, 2021 7 hours ago, harinezumi said: Hi Lee Mac, Thank you for your code. I try it in acad 2021 but I get the error: when loading then when running. Can you please help? Thank you An update to the forum software some time ago had removed "8 )" from the LM:RGB->True function - I've now updated my earlier post to correct the code. Quote
Slava Posted February 8 Posted February 8 On 4/5/2021 at 6:13 PM, harinezumi said: Hi Lee Mac, Thank you for your code. I need Lisp for chenge layer color to RGB. Some layers already have RGB Color and all objekts by layer. Can you please help? Quote
pkenewell Posted February 8 Posted February 8 2 hours ago, Slava said: Did you look here? https://www.lee-mac.com/colourconversion.html Quote
Slava Posted February 11 Posted February 11 Yes. I tried to understand this without success. 1.Where "defan c:"? 2.This will change the color of the layer or object? Quote
Lee Mac Posted February 12 Posted February 12 On 2/11/2024 at 10:36 AM, Slava said: Yes. I tried to understand this without success. 1.Where "defan c:"? 2.This will change the color of the layer or object? These are functions which may be called from other programs - they are not commands which can be executed at the command line. Quote
Dien nguyen Posted March 3 Posted March 3 I used this lisp to convert the color of the object to true color. Now I'm looking for a way to change the color of all layers from RGB to TrueColor. I consulted Lee-Mac's website but I still don't know how to use it. Please help. Quote
Recommended Posts
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.