jim78b Posted November 14, 2019 Posted November 14, 2019 hello i have this lisp but i want change from color 230,230,219 to black and reverse, i don't know the ole code. or there is a quick way? thanks Quote ;;; Website: www.jtbworld.com ;;; E-mail: info@jtbworld.com ;;; 2003-07-01 - First release ;;; Tested on AutoCAD 2002, 2004, 2005 ; Set the background in model and paper space to grey (defun c:BGGrey () (vl-load-com) (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object)))) (vla-put-GraphicsWinModelBackgrndColor disp 5987163) (vla-put-GraphicsWinLayoutBackgrndColor disp 5987163) (vla-put-LayoutCrosshairColor disp 16777215) (vla-put-ModelCrosshairColor disp 16777215) (vla-put-AutoTrackingVecColor disp 16777215) (vla-put-AutoSnapMarkerColor drafting 2) (princ) ) ; Set the background in model and paper space to white (defun c:BGWhite () (vl-load-com) (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object)))) (vla-put-GraphicsWinModelBackgrndColor disp 16777215) (vla-put-GraphicsWinLayoutBackgrndColor disp 16777215) (vla-put-LayoutCrosshairColor disp 0) (vla-put-ModelCrosshairColor disp 0) (vla-put-AutoTrackingVecColor disp 0) (vla-put-AutoSnapMarkerColor drafting 6) (princ) ) ; Set the background in model and paper space to black (defun c:BGBlack () (vl-load-com) (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object)))) (vla-put-GraphicsWinModelBackgrndColor disp 0) (vla-put-GraphicsWinLayoutBackgrndColor disp 0) (vla-put-LayoutCrosshairColor disp 16777215) (vla-put-ModelCrosshairColor disp 16777215) (vla-put-AutoTrackingVecColor disp 16777215) (vla-put-AutoSnapMarkerColor drafting 2) (princ) ) ; Background toggle between black and white (defun c:bgt () (vl-load-com) (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object)))) (if (= (vlax-variant-value (vlax-variant-change-type (vla-get-graphicswinmodelbackgrndcolor disp) vlax-vblong ) ) 0 ) (c:bgwhite) (c:bgblack) ) (princ) ) (princ) Quote
rlx Posted November 14, 2019 Posted November 14, 2019 1 minute ago, jim78b said: How do you calcolate it? I didn't... you mentioned color 230,230,219 so I put it in thru the options dialog. when I see (vla-put-GraphicsWinModelBackgrndColor disp 16777215) I assumed there must be a 'get' version of the command. So I googled vla-GET-GraphicsWinModelBackgrndColor and found it in the autodesk help file , with example. So I used the example to get the background color after I changed it by hand... the name is Holmes , Sherlock Holmes Quote
jim78b Posted November 14, 2019 Author Posted November 14, 2019 Thanks i try to put it in code. Quote
dlanorh Posted November 14, 2019 Posted November 14, 2019 39 minutes ago, jim78b said: How do you calcolate it? http://www.lee-mac.com/colourconversion.html Quote
jim78b Posted November 14, 2019 Author Posted November 14, 2019 THANKS BUT I MUST CREATE A LISP FOR THAT? Quote
BIGAL Posted November 15, 2019 Posted November 15, 2019 You could do the same in excel to calculate the number But this line is required to change (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) any of the properties. There is probably a registery setting somewhere. But again do you use lisp to change. 1 Quote
tombu Posted November 15, 2019 Posted November 15, 2019 I've used Jimmy Bergmark's code since he first posted it saved as "BackgroundChanger.LSP". We often get drawings from consultants with dark linework that can only be displayed on a white background. When Lee Mac posted his color conversion code I replaced everything above: ; Set the background in model and paper space to grey with: ;;; E-mail: info@jtbworld.com ;;; http://jtbworld.com/autocad-backgroundchanger-lsp ;;; 2003-07-01 - First release ;;; (load "BackgroundChanger.LSP") bgtg ;;; Macro: ^P(or bgtg (load "BackgroundChanger.LSP"));bgtg ;;; RCDATA_16_COLOR ;; RGB -> OLE - Lee Mac - Args: r,g,b - [int] Red, Green, Blue values ;; http://www.lee-mac.com/colourconversion.html#rgbole ;; ex. (LM:RGB->OLE 33 40 48) returns 3156001 (defun LM:RGB->OLE ( r g b )(logior (fix r) (lsh (fix g) 8) (lsh (fix b) 16))) ;; OLE -> RGB - Lee Mac - Args: c - [int] OLE Colour (defun LM:OLE->RGB ( c )(mapcar '(lambda ( x ) (lsh (lsh (fix c) x) -24)) '(24 16 8))) ;; ex. (LM:OLE->RGB 3156001) returns (33 40 48) Once it's loaded entering (LM:RGB->OLE 230 230 219) returns 14411494 Since I use the standard 33,40,48 as my BGGrey Background color I added the function: ; Background toggle between grey and white (defun c:bgtg () (vl-load-com) (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object)))) (setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object)))) (if (= (vlax-variant-value (vlax-variant-change-type (vla-get-graphicswinmodelbackgrndcolor disp) vlax-vblong ) ) (LM:RGB->OLE 33 40 48) ) (c:BGWhite) (c:BGGrey) ) (princ) ) which is just his bgt function modified to toggle to grey instead of black. 1 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.