Uniform background Color

Uniform background Color

W_T_
Advocate Advocate
1,065 Views
12 Replies
Message 1 of 13

Uniform background Color

W_T_
Advocate
Advocate

Can it be controlled by LISP?

W_T__0-1702855464023.png

 

0 Likes
Accepted solutions (2)
1,066 Views
12 Replies
Replies (12)
Message 2 of 13

paullimapa
Mentor
Mentor
Accepted solution
0 Likes
Message 3 of 13

komondormrex
Mentor
Mentor

how do you want to control it exactly?

0 Likes
Message 4 of 13

W_T_
Advocate
Advocate

My thoughts change the background color, but it is a photographic process without law.

(defun c:ChangeBW (/)    
 (if (= (getvar "Background") 0)   
   (progn              
     (setvar "background" 16777215);Color:White
   )                    
   (progn              
     (setvar "background" 0);Color:Black
   )                    
 ) ; End if                     
 (princ)               
) 

 

0 Likes
Message 5 of 13

W_T_
Advocate
Advocate

Thank you .

but, there is no work on the bottom side.

 

(getenv "Background")

 

0 Likes
Message 6 of 13

paullimapa
Mentor
Mentor

Of course that doesn’t work. How come you didn’t try the code that is already done for you in the link I provided before?

For example this one called tbk.lsp can Toggle the Background color between Black. & White:

(defun c:tbk(/ ) ;;(prefDisplay) ;;Toggle background
(setq prefDisplay(vla-get-Display(vla-get-Preferences(vlax-get-acad-object))))
(setq color(vlax-variant-value(vlax-variant-change-type
(vla-get-GraphicsWinModelBackgrndColor prefDisplay)vlax-vbLong)))
(vla-put-GraphicsWinModelBackgrndColor prefDisplay
(vlax-make-variant(if(= color 0) 16777215 0) vlax-vbLong))
(princ))

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 7 of 13

komondormrex
Mentor
Mentor
Accepted solution

function cycle_bwo_background cycles thru black and white backgrounds in model and paper spaces

 
(defun cycle_bwo_background ( / display_settings _space back_color)
	(if (= "*Paper_Space" (vla-get-name
							(vla-get-block
								(vla-get-activelayout
									(vla-get-ActiveDocument
										(vlax-get-acad-object)
									)
								)
							)
						  )
		)
		(setq _space "graphicswinlayoutbackgrndcolor")
		(setq _space "graphicswinmodelbackgrndcolor")
	)
	(setq back_color (vlax-variant-value
						(vlax-variant-change-type
							((eval (read (strcat "vla-get-" _space)))
								(setq display_settings
									(vla-get-display
										(vla-get-preferences
											(vlax-get-acad-object)
										)
									)
								)
							)
							vlax-vbLong
						)
					 )
	)
	(if (null (eval (read _space)))
		(set (read _space) back_color)
		(if (and
				(/= back_color (eval (read _space)))
				(/= 0 back_color)
				(/= 16777215 back_color)
			)
				(set (read _space) back_color)
		)
	)
	(cond
		(
			(and
				(eval (read _space))
				(/= 0 back_color)
				(/= 16777215 back_color)
			)
				((eval (read (strcat "vla-put-" _space))) display_settings 0)
		)
		(
			(zerop back_color)
				((eval (read (strcat "vla-put-" _space))) display_settings 16777215)
		)
		(
			(and
				(= 16777215 back_color)
				(/= 0 (eval (read _space)))
				(/= 16777215 (eval (read _space)))
			)
				((eval (read (strcat "vla-put-" _space))) display_settings (eval (read _space)))
		)
		(
			t
				(if (= 16777215 back_color)
					((eval (read (strcat "vla-put-" _space))) display_settings 0)
					((eval (read (strcat "vla-put-" _space))) display_settings 16777215)
				)
		)
	)
	(princ)
)

 

0 Likes
Message 8 of 13

W_T_
Advocate
Advocate

Is it possible or not to actually see the three-faced cycle?
White
black
yellow

0 Likes
Message 9 of 13

komondormrex
Mentor
Mentor

it is already three-faced. the third (other) is one you've set manually and which is different from black or white. in that case function will cycle backgrounds thru black, white and other background. once you set it yellow, it will cycle it too.

 

or you want to cycle thru black white and yellow in either background setting?

0 Likes
Message 10 of 13

komondormrex
Mentor
Mentor

to cycle thru a black, white,and  yellow background

;****************************************************************************************************************************************

(defun split_list_nth (_list _nth)
  	(if (>= _nth 0) (set 'split_before_nth (cons (car _list) (split_list_nth (set 'split_after_nth (cdr _list)) (1- _nth)))))
)

;****************************************************************************************************************************************

(defun cycle_bwy_background ( / display_settings _space back_color split_after_nth split_before_nth _space display_settings back_color)
	(if (= "*Paper_Space" (vla-get-name (vla-get-block (vla-get-activelayout (vla-get-ActiveDocument (vlax-get-acad-object))))))
		(setq _space "graphicswinlayoutbackgrndcolor")
		(setq _space "graphicswinmodelbackgrndcolor")
	)
	(setq back_color (vlax-variant-value (vlax-variant-change-type ((eval (read (strcat "vla-get-" _space)))
																  		(setq display_settings
																  				(vla-get-display
																  					(vla-get-preferences
																  						(vlax-get-acad-object)
																  					)
																  				)
																  		)
																	)
																	vlax-vblong
										)
					 )
		  cycle_values (if (null cycle_values) 
							(if (not (member back_color '(0 16777215 65535)))
									(list 0 16777215 65535 back_color)
									(progn 
										(split_list_nth '(0 16777215 65535) (vl-position back_color '(0 16777215 65535)))
										(append split_after_nth split_before_nth)  
									)
							)
							(progn
								(setq cycle_values (vl-remove-if-not '(lambda (list_member) (member list_member '(0 16777215 65535))) cycle_values))
								(if (not (member back_color cycle_values))
									(progn
										(split_list_nth cycle_values (vl-position 65535 cycle_values))
										(append split_before_nth (list back_color) split_after_nth) 
									)
									cycle_values
								)
							)
					   )   
	)
	((eval (read (strcat "vla-put-" _space))) display_settings (car cycle_values))
	(setq cycle_values (append (cdr cycle_values) (list (car cycle_values))))
	(princ)
)

;****************************************************************************************************************************************
Message 11 of 13

dlbsurveysuk
Collaborator
Collaborator

Am I correct that this only works in 2D model space, and it is not possible to make it work in 3D space?

0 Likes
Message 12 of 13

paullimapa
Mentor
Mentor
0 Likes
Message 13 of 13

dlbsurveysuk
Collaborator
Collaborator

OK. Yeah I thought so. Having to close and reopen the drawing is no good for me.

 

It would be useful to change the background colour on the fly in 3D space (I use point clouds and the background colour greatly effects the visual appearance of the point cloud).

 

Thanks.

0 Likes