Jump to content

Recommended Posts

Posted

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)

 

 

Posted
1 minute ago, jim78b said:

How do you calcolate it?

 

I didn't... :P

 

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 😄

Posted

THANKS BUT I MUST CREATE A LISP FOR THAT?

Posted

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.

  • Like 1
Posted

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.

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...