rookie37 Posted July 2, 2008 Posted July 2, 2008 How do I write a lisp routine that will convert true colors? I.E. psydocode Group properties 240,0,0 (true red) Change to color 1 (red) Group properties 247,247,0 (true yellow) Change to color 2 (yellow) Group properties 0,0,248 (true blue) Change to color 5 (blue) Any help would be greatly appreciated Quote
ASMI Posted July 2, 2008 Posted July 2, 2008 Piece of stupid "command style" code without restore original colors, but it works: (defun c:ccol() (command "_.change" (ssget "_X" '((420 . 15728640))) "" "_pr" "_c" "1" "") (command "_.change" (ssget "_X" '((420 . 16250624))) "" "_pr" "_c" "2" "") (command "_.change" (ssget "_X" '((420 . 248))) "" "_pr" "_c" "5" "") (princ) ); end of c:ccol If you want to have posibility of restoration of colors I can write it. But it more long code. If not, it solve your problem. Quote
rookie37 Posted July 4, 2008 Author Posted July 4, 2008 Thank you very much. It works great! I have to add to it 0,248,248 = color 4 (cyan) I was going to do this myself but I can't follow it 240,0,0 is the true color of red. What is 420 . 15728640 ? Where can I find out what the value of other true colors so that I can add to this myself Quote
ASMI Posted July 4, 2008 Posted July 4, 2008 240,0,0 is the true color of red. What is 420 . 15728640 ? It's DXF-coding of True Color. Type (entget(car(entsel))) in command line, pick some true color entity and find of this dotted pair value. Command: (entget(car(entsel))) Select object: ((-1 . <Entity name: 7efab218>) (0 . "LINE") (330 . <Entity name: 7efa3cf8>) (5 . "133") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (62 . 4) [color="Blue"](420 . 63736)[/color] (100 . "AcDbLine") (10 739.081 397.75 0.0) (11 1104.26 546.664 0.0) (210 0.0 0.0 1.0)) Quote
rookie37 Posted July 6, 2008 Author Posted July 6, 2008 Thank you very much! (again) It works great! (again) I gather that 420 means color What do the other things mean? Quote
ASMI Posted July 7, 2008 Posted July 7, 2008 What do the other things mean? For example: 0 - entity type, 8 -layer, 10 and 11 -start and end points (for line). Complete info in Help>Additional Resources>Developer Help>DXF Reference. Quote
SteveK Posted May 26, 2009 Posted May 26, 2009 ASMI, regarding the ccol "command style" code; It searches the whole drawing but does not include blocks. Is it hard to add the ability for it to include blocks as well? Rather than having to explode or use the 'block editor'. Thanks Quote
SteveK Posted June 9, 2009 Posted June 9, 2009 Just to respond to myself: Continuing on with "command style" code (Cause that's all I know) I updated it to at least work in the block one selects. This works ok for Xl2Cad. To get it to apply to everything within a drawing (including blocks) is my aim. (defun c:cc(/ Col1 Col2 Col3 Col4 Col5) ;Program Opens selected block and updates certain colours (command "_.-refedit" pause "_Ok" "_All" "_n") ;Colours in excel (Setq Col1 (ssget "_X" '((420 . 16711680)))) ;Red in Excel (Setq Col2 (ssget "_X" '((420 . 255)))) ;Blue in Excel (Setq Col3 (ssget "_X" '((420 . 16737792)))) ;Orange in Excel (Setq Col4 (ssget "_X" '((420 . 8421504)))) ;Dark Grey in Excel (Setq Col5 (ssget "_X" '((420 . 52479)))) ;Sky Blue in Excel ;If it's not empty then change the colour (If (Not (= Col1 nil)) (command "_.change" Col1 "" "_pr" "_c" "1" "") ;Change to Red in ACad (Setq Col1 nil) ) (If (Not (= Col2 nil)) (command "_.change" Col2 "" "_pr" "_c" "11" "") ;Change to Colour 11 in ACad (Setq Col2 nil) ) (If (Not (= Col3 nil)) (command "_.change" Col3 "" "_pr" "_c" "2" "") ;Change to Yellow in ACad (Setq Col3 nil) ) (If (Not (= Col4 nil)) (command "_.change" Col4 "" "_pr" "_c" "8" "") ;Change to Grey (Colour in Acad (Setq Col4 nil) ) (If (Not (= Col5 nil)) (command "_.change" Col5 "" "_pr" "_c" "140" "");Change to Colour 140 in ACad (Setq Col5 nil) ) ;close and save block (command "_.refclose" "_Save") (princ)) Quote
alanjt Posted June 9, 2009 Posted June 9, 2009 I gather that 420 means color lol among other things 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.