Grid Lines Color and Luminance

Grid Lines Color and Luminance

Anonymous
해당 사항 없음
1,359 조회수
9 답변
1/10 메시지

Grid Lines Color and Luminance

Anonymous
해당 사항 없음

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
수락된 솔루션(1)
1,360 조회수
9 답변
답변 (9)
2/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
3/10 메시지

Anonymous
해당 사항 없음

@CodeDing ,

 

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

 

Thanks

0 Likes
4/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
5/10 메시지

hmsilva
Mentor
Mentor
수락된 솔루션

@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

6/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
7/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

8/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.
9/10 메시지

Anonymous
해당 사항 없음

@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
10/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