Grid Lines Color and Luminance

Grid Lines Color and Luminance

Anonymous
Not applicable
1,329 Views
9 Replies
Message 1 of 10

Grid Lines Color and Luminance

Anonymous
Not applicable

AutoCAD Mechanical 2019

Is there a way to change the grid color (F7) and the luminance (options) using a LISP routine.  I have a routine that changes the background color to white but I have not been able to find the grid color or the luminance. 

  (vl-load-com)
  (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
  (vla-put-GraphicsWinModelBackgrndColor disp 16777215)
  (vla-put-GraphicsWinLayoutBackgrndColor disp 16777215)

 

 

0 Likes
Accepted solutions (1)
1,330 Views
9 Replies
Replies (9)
Message 2 of 10

CodeDing
Advisor
Advisor

@Anonymous ,

 

Based on the PreferencesDisplay Object, I do not think we will be able to accomplish that with VisualLISP.

I'm not the most experienced with VisualLISP, so maybe someone can prove me wrong.

 

Best,

~DD

0 Likes
Message 3 of 10

Anonymous
Not applicable

@CodeDing ,

 

Well that's a bummer.  Is there another way to do it?

 

Thanks

0 Likes
Message 4 of 10

CodeDing
Advisor
Advisor

@Anonymous ,

 

Well, I do not believe this can be accomplished with AutoLISP... IF there is a registry key that controls this color, then it could be accomplished via Visual LISP (but I am not sure how to find the registry key for such a value). Otherwise, a .NET approach is capable of accomplishing about 99.9% of all things, but I am no pro there either so you would need to ask that forum if they could help via that method.

 

Best,

~DD

0 Likes
Message 5 of 10

hmsilva
Mentor
Mentor
Accepted solution

@Anonymous wrote:

AutoCAD Mechanical 2019

Is there a way to change the grid color (F7) and the luminance (options) using a LISP routine.  I have a routine that changes the background color to white but I have not been able to find the grid color or the luminance. 

  (vl-load-com)
  (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
  (vla-put-GraphicsWinModelBackgrndColor disp 16777215)
  (vla-put-GraphicsWinLayoutBackgrndColor disp 16777215)

 

 


Hi @Anonymous 

using system environment variables is possible.

 

Grid color environment variables:

2D Model grid minor lines color
2D Model grid major lines color
BEdit grid minor lines color
BEdit grid major lines color
Layout grid minor lines tint
Layout grid major lines color
Parallel grid minor lines color
Parallel grid major lines color
Perspective grid minor lines color
Perspective grid major lines color

 

Use getenv and setenv functions

 

Hope this helps,
Henrique

EESignature

Message 6 of 10

CodeDing
Advisor
Advisor

@hmsilva ,

 

Where did you find those environment variables? Is there a website listing them?

The only Environnment Variables that I have mainly ever used I can only find on the AfraLisp site.

 

Glad you posted them!

 

Best,

~DD

 

0 Likes
Message 7 of 10

hmsilva
Mentor
Mentor

@CodeDing wrote:

@hmsilva ,

 

Where did you find those environment variables? Is there a website listing them?

The only Environnment Variables that I have mainly ever used I can only find on the AfraLisp site.

 

Glad you posted them!

 

Best,

~DD

 


Hi @CodeDing 

I don't know any list with all system environment variables.

We have to search in registry...

 

Henrique

EESignature

Message 8 of 10

hak_vz
Advisor
Advisor

@CodeDing wrote:

@hmsilva ,

 

Where did you find those environment variables? Is there a website listing them?

The only Environnment Variables that I have mainly ever used I can only find on the AfraLisp site.


You can find some of this variables in exported profile file, where it shows how they are written in registry.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 9 of 10

Anonymous
Not applicable

@hmsilva 

This greatly helped me to make the code below. 

Any idea how the numbers relate to colors, in case users want different colors?

Example:

0-black

255 - red

16767446 - light grey?

 

Thanks

 

; TURNS ON GRID, SETS PAPERSPACE MAJOR AND MINOR LINE COLOR TO MATCH MODELSPACE SETTINGS
(defun c:gridmatch(/ minor major)

	(setvar "cmdecho" 0)
	
; TURNS ON GRID 

	(command "grid" "on" "")

; GETS COLOR OF MINOR AND MAJOR GRID LINES FROM MODELSPACE

	(setq minor (getenv "2D Model grid minor lines color"))
	(setq major (getenv "2D Model grid major lines color"))

; SETS COLOR OF MINOR AND MAJOR PAPERSPACE GRID LINES TO MATCH MODELSPACE

	(setenv "Layout grid minor lines color" minor)
	(setenv "Layout grid major lines color" major)

; REGENS ALL

	(command "REGENALL")

	(setvar "cmdecho" 1)
)

 

0 Likes
Message 10 of 10

hmsilva
Mentor
Mentor

@Anonymous wrote:

@hmsilva 

This greatly helped me to make the code below. 

Any idea how the numbers relate to colors, in case users want different colors?

Example:

0-black

255 - red

16767446 - light grey?

 

Thanks

 

...


Hi @Anonymous  @Lee_Mac 's Colour Conversion Functions are a great help. 

To get a true color from  a ACI (AutoCAD Colour Index) try ' LM:ACI->True' function.

 

Hope this helps,
Henrique

EESignature