Thank you. I thought about it before I post, but I didn't believe it might be working.
I forgot that before '(setq zbior (ssget))' there is a prompt "Select objects: ".
I thought it will not be prompted.
By the way, gpcattaneo's lisp for "Change CrossHair Color via DialogBox" works very good, so on ground of it I wanted to write lisp for "Change Background Color via DialogBox".
On http://www.afralisp.net/archive/lisp/enviro.htm I found, that the good expression is "Background".
So I thought, that in gpcattaneo's lisp I shoul change "XhairPickboxEtc" to "Background".
And I did so. Here is this lisp:
; Displays ColorPalette, but doesn't apply the chosen color
; to the BackGround color.
; http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/system-variable-for-crosshair-color/td-p/5480926
; On ground of lisp "Change CrossHair Color via DialogBox" by gpcattaneo
; Originally, there was CCCH
; CCBGGP = Change Color BackGround GPcattaneo
(defun c:CCBGGP ( / c )
(if (setq c (acad_colordlg 7 nil))
(setenv "Background" (itoa (LM:ACI->OLE c)))
)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; by Lee Mac ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; http://lee-mac.com/colourconversion.html ;;;;;;;;;;;;;;;
;;;; Colour Conversion Functions ;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ACI -> OLE - Lee Mac
;; Args: c - [int] ACI (AutoCAD Colour Index) Colour (1<=c<=255)
(defun LM:ACI->OLE ( c )
(apply 'LM:RGB->OLE (LM:ACI->RGB c))
)
;; RGB -> OLE - Lee Mac
;; Args: r,g,b - [int] Red, Green, Blue values
(defun LM:RGB->OLE ( r g b )
(logior (fix r) (lsh (fix g) 8) (lsh (fix b) 16))
)
;; ACI -> RGB - Lee Mac
;; Args: c - [int] ACI (AutoCAD Colour Index) Colour (1<=c<=255)
(defun LM:ACI->RGB ( c / o r )
(if (setq o (vla-getinterfaceobject (LM:acapp) (strcat "autocad.accmcolor." (substr (getvar 'acadver) 1 2))))
(progn
(setq r
(vl-catch-all-apply
'(lambda ( )
(vla-put-colorindex o c)
(list (vla-get-red o) (vla-get-green o) (vla-get-blue o))
)
)
)
(vlax-release-object o)
(if (vl-catch-all-error-p r)
(prompt (strcat "\nError: " (vl-catch-all-error-message r)))
r
)
)
)
)
;; Application Object - Lee Mac
;; Returns the VLA Application Object
(defun LM:acapp nil
(eval (list 'defun 'LM:acapp 'nil (vlax-get-acad-object)))
(LM:acapp)
)
(vl-load-com) (princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CCBLGGP = Change Color Layout BackGround GPcattaneo
(defun c:CCLBGGP ( / c )
(if (setq c (acad_colordlg 7 nil))
(setenv "Layout background" (itoa (LM:ACI->OLE c)))
)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; by Lee Mac ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; http://lee-mac.com/colourconversion.html ;;;;;;;;;;;;;;;
;;;; Colour Conversion Functions ;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ACI -> OLE - Lee Mac
;; Args: c - [int] ACI (AutoCAD Colour Index) Colour (1<=c<=255)
(defun LM:ACI->OLE ( c )
(apply 'LM:RGB->OLE (LM:ACI->RGB c))
)
;; RGB -> OLE - Lee Mac
;; Args: r,g,b - [int] Red, Green, Blue values
(defun LM:RGB->OLE ( r g b )
(logior (fix r) (lsh (fix g) 8) (lsh (fix b) 16))
)
;; ACI -> RGB - Lee Mac
;; Args: c - [int] ACI (AutoCAD Colour Index) Colour (1<=c<=255)
(defun LM:ACI->RGB ( c / o r )
(if (setq o (vla-getinterfaceobject (LM:acapp) (strcat "autocad.accmcolor." (substr (getvar 'acadver) 1 2))))
(progn
(setq r
(vl-catch-all-apply
'(lambda ( )
(vla-put-colorindex o c)
(list (vla-get-red o) (vla-get-green o) (vla-get-blue o))
)
)
)
(vlax-release-object o)
(if (vl-catch-all-error-p r)
(prompt (strcat "\nError: " (vl-catch-all-error-message r)))
r
)
)
)
)
;; Application Object - Lee Mac
;; Returns the VLA Application Object
(defun LM:acapp nil
(eval (list 'defun 'LM:acapp 'nil (vlax-get-acad-object)))
(LM:acapp)
)
(vl-load-com) (princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CCLCHGP = Change Color Layout Crosshair GPcattaneo
(defun c:CCLCHGP ( / c )
(if (setq c (acad_colordlg 7 nil))
(setenv "LayoutXhairPickboxEtc" (itoa (LM:ACI->OLE c)))
)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; by Lee Mac ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; http://lee-mac.com/colourconversion.html ;;;;;;;;;;;;;;;
;;;; Colour Conversion Functions ;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ACI -> OLE - Lee Mac
;; Args: c - [int] ACI (AutoCAD Colour Index) Colour (1<=c<=255)
(defun LM:ACI->OLE ( c )
(apply 'LM:RGB->OLE (LM:ACI->RGB c))
)
;; RGB -> OLE - Lee Mac
;; Args: r,g,b - [int] Red, Green, Blue values
(defun LM:RGB->OLE ( r g b )
(logior (fix r) (lsh (fix g) 8) (lsh (fix b) 16))
)
;; ACI -> RGB - Lee Mac
;; Args: c - [int] ACI (AutoCAD Colour Index) Colour (1<=c<=255)
(defun LM:ACI->RGB ( c / o r )
(if (setq o (vla-getinterfaceobject (LM:acapp) (strcat "autocad.accmcolor." (substr (getvar 'acadver) 1 2))))
(progn
(setq r
(vl-catch-all-apply
'(lambda ( )
(vla-put-colorindex o c)
(list (vla-get-red o) (vla-get-green o) (vla-get-blue o))
)
)
)
(vlax-release-object o)
(if (vl-catch-all-error-p r)
(prompt (strcat "\nError: " (vl-catch-all-error-message r)))
r
)
)
)
)
;; Application Object - Lee Mac
;; Returns the VLA Application Object
(defun LM:acapp nil
(eval (list 'defun 'LM:acapp 'nil (vlax-get-acad-object)))
(LM:acapp)
)
(vl-load-com) (princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
But it doesn't work.
Can you tell me why?
Generally, I will be write such lisp for "Layout background", "XhairPickboxEtc", too.