Changing Page Layout paper background via lisp.

Changing Page Layout paper background via lisp.

LDShaw
Collaborator Collaborator
6,261 Views
18 Replies
Message 1 of 19

Changing Page Layout paper background via lisp.

LDShaw
Collaborator
Collaborator

I need to change some of the drawing background colors throughout the company. For the most part I've been able to find the ones I want.
Can anyone point me to a list of variables for colors or just tell me the one I need?
I am thinking something along the lines of

GraphicsWinlayoutPaperColor but that one did not work.

background.PNG
An example of one I know is.
(vlax-put-property acaddisp 'ModelCrosshairColor 16777215)

Thanks for any help.

0 Likes
Accepted solutions (2)
6,262 Views
18 Replies
Replies (18)
Message 2 of 19

devitg
Advisor
Advisor

(defun set-croos-hair-color () (vl-load-com) (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT)) ;_ THE ACAD OBJECT (setq preferences-acad-obj (vla-get-preferences ACAD-OBJ)) (setq preferencesDisplay (vla-get-display preferences-acad-obj)) (setq color (ACAD_COLORDLG 1 )) (vlax-put-property preferencesDisplay 'ModelCrosshairColor color ) )

Try it 

0 Likes
Message 3 of 19

LDShaw
Collaborator
Collaborator

That did not quite do what I need.

 

this is what I have that works so far (Barring the green line.)

(setq acadobject (vlax-get-acad-object))
(setq acadpref (vlax-get-property acadobject 'preferences))
(setq acaddisp (vlax-get-property acadpref 'display))
(vlax-put-property acaddisp 'GraphicsWinmodelBackgrndColor 0)  ;;Model space background
(vlax-put-property acaddisp 'ModelCrosshairColor 16777215)  ;; crosshairs
(vlax-put-property acaddisp 'TextWinBackgrndColor 16777215)  ;;command area

 

(vlax-put-property acaddisp 'XXXXXX 16777215)  ;;sheet layout area

 

I just need the call for Sheet/layout  Paper background
(The highlighted part in the jpg I attached in my original post.)

Hope that clears it up somewhat and I do appreciate the help.

 

0 Likes
Message 4 of 19

devitg
Advisor
Advisor

Hi Ishaw , please state what color you want to change 

 

The blue or the red 

 

 

wich one you want to change.PNG

0 Likes
Message 5 of 19

LDShaw
Collaborator
Collaborator

The blue color.

 

Sorry I was not very clear on it what I wanted to change.

I should have said.
Sheet/layout>>Paper background.


Thanks.

0 Likes
Message 6 of 19

devitg
Advisor
Advisor
Ishaw , sad to notice you, that I can not find such PROPERTY , maybe other user can help us,
0 Likes
Message 7 of 19

LDShaw
Collaborator
Collaborator

Thanks for the try.

I remember someone finding all of these by doing an export autocad settings and digging them out of one of those files. I was kinda hoping someone would be able to point me to the right file in the zip. I figure if I can just find the names I will be fine.

0 Likes
Message 8 of 19

devitg
Advisor
Advisor

As far as I know , all settings done by OPTION , is filed in a *.arg file 

0 Likes
Message 9 of 19

devitg
Advisor
Advisor

As far as I know , all settings done by OPTION , is filed in a *.arg file Find attached the arg file for a red paper space background, both are the same , it is a txt file , I change the extension to TXT from a copy So then seem to be it need to be handle by REGISTER KEY . SEE AT , 2016-red background-AND-2016WHITE BACGROUND - copia.TXT , LINE 197 WHERE THE VALUE IS CHANGED Paper background=dword:000000FF For white background 000000FF Paper background=dword:00FFFFFF For red background 00FFFFFF I NEVER TRY TO CHANGE A REGISTRY KEY , BUT IT CAN BE DO. Also you can set to import your ARG file to all yours ACAD user. Neither I know how to do it in LISP.

0 Likes
Message 10 of 19

devitg
Advisor
Advisor
Find the attached text file , with a clear explanation
0 Likes
Message 11 of 19

Ranjit_Singh
Advisor
Advisor

Use the environment variable Paper background

(setenv "Paper background" "12566463")

I am using my background as example where the color for my paper background is 191 191 191. The RGB color needs to be passed as True color.

 

Message 12 of 19

devitg
Advisor
Advisor

How to convert RGB color to TRUE COLOR ?

0 Likes
Message 13 of 19

Ranjit_Singh
Advisor
Advisor

Try this code

(defun RGBToTrueColor (rgb)
 (setq r (lsh (car rgb) 16))
 (setq g (lsh (cadr rgb) 8))
 (setq b (caddr rgb))
 (setq tcol (+ (+ r g) b)) 
) 

Hope it helps. I found the code here RGB to True Color

 

Message 14 of 19

Ranjit_Singh
Advisor
Advisor

make sure to pass RGB as a list. For ex. you will call the function

(RGBtoTrueColor  '(191 191 191))
0 Likes
Message 15 of 19

LDShaw
Collaborator
Collaborator
Accepted solution

I thought I'd come back around to this. I ended up finding what I wanted to change by typing this.

(vlax-dump-object (vla-get-display (vla-get-preferences (vlax-get-Acad-object))) T

I then sorted out what colors I wanted to change. I don't know if this gives a complete list but it gave me what I needed.

BTW

(vlax-dump-object (vla-get-preferences (vlax-get-Acad-object)) T)


Will give you the Tab names to drill down and find what you need.



 

0 Likes
Message 16 of 19

Anonymous
Not applicable

I know this page is marked as "solved", but did you end up finding the 'vla-put..' for the blue space?? I can't seem to see it here..

0 Likes
Message 17 of 19

Anonymous
Not applicable

I know this post is quite old now but for the sake of providing a solution for others, to change the 'blue' area (from grey to whatever the paper colour is ie. black), you can simply go:
Command:Options > Display Tab > Layout elements > Untick the Display paper background.

 

If you'd like to do this in lisp:

(vl-load-com)
(setq DisObj (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
(setq drafting (vla-get-drafting (vla-get-preferences (vlax-get-acad-object))))
(vlax-put DisObj "LayoutDisplayPaper" 0)
(princ)

Alternatively, you can keep the keep the DisplayPaperBackground ticked on, & change the colour of it to whatever you want with:

(setenv "Paper background" "12566463") ;this number = 191,191,191 = grey area around paper

;; Black=0, Red=255, Blue=16711680, White=16777215 - google 'VBA.ColorConstants'



Hope this is of some help!

0 Likes
Message 18 of 19

LDShaw
Collaborator
Collaborator
Accepted solution

Wow it's been a while since I had to think about this one.

yes. Here is what I wrote to get it done. 

(setq acadobject (vlax-get-acad-object))
(setq acadpref (vlax-get-property acadobject 'preferences))
(setq acaddisp (vlax-get-property acadpref 'display))
(vlax-put-property acaddisp 'GraphicsWinmodelBackgrndColor 1423) ;;Model space background
(vlax-put-property acaddisp 'GraphicsWinLayoutBackgrndColor  0) ;;command area
(vlax-put-property acaddisp 'ModelCrosshairColor 16777215) ;; crosshairs
(vlax-put-property acaddisp 'TextWinBackgrndColor 16777215) ;;command area



0 Likes
Message 19 of 19

heather_o
Enthusiast
Enthusiast

I'm going down the rabbit hole trying to write a simple LSP routine and I'm hoping y'all can help me.  I want a lsp "BG" (background)  I only want 2 options.  White background or Black background.  All the routines I'm seeing look like novels to me 🙂  

I thought I could create a different workspace with the different backgrounds, but that didn't work.  

Any advise/help would be greatly appreciated

0 Likes