Short description
đ¨ ChangeBackgroundColor is an AutoCAD and Civil 3D AutoLISP utility for changing Model Space, Paper Space, and Block Editor background colors from commands or a DCL dialog.
đąī¸ It also adjusts crosshair, AutoTracking vector, and AutoSnap marker colors so the interface remains readable after the background change.
Command:
đ Main command: BG
đ§° Dialog command: BGDCL
âĢ Quick command: BGBlack
âĒ Quick command: BGWhite
đŠļ Quick command: BGGrey
đ Toggle command: BGT
đ¨ The dialog provides global color mode, individual Model/Paper/Block Editor color selectors, Apply, OK, and Cancel.
Description:
đ¨ ChangeBackgroundColor is an SEO-friendly AutoCAD background color manager for CAD users who switch between black, white, grey, and custom workspace visibility setups.
đ§° The BGDCL dialog is created dynamically as a temporary DCL file and lets the user apply one global color or assign different colors to Model Space, Paper Space, and Block Editor.
đī¸ The routine updates display readability by changing crosshair color, AutoTracking vector color, and AutoSnap marker color according to the selected background.
đ§ą Block Editor background is handled through the BEditBackground environment setting using a BGR decimal value, avoiding ARG file patching or registry edits.
âŠī¸ The dialog stores a snapshot of the current colors and restores it if the user cancels.
Helper function: (if any)â
đ§Š _rgb->long converts RGB values to AutoCAD long color values.
đ§Š _rgb->bgr converts RGB long values to BGR values for BEditBackground.
đ§Š _snapshot-current records Model Space, Paper Space, Block Editor, crosshair, tracking, and AutoSnap colors before dialog changes.
đ§Š _restore-snapshot restores the previous display settings when the dialog is canceled.
đ§Š _apply-space applies selected background colors to the chosen drawing spaces.
đ§Š _bg-dcl-source and _write-dcl-unique generate the temporary DCL interface.
đ§Š _bg-sync-enable enables or disables individual color controls when Global Color is toggled.
đ§Š _be-get-bg and _be-put-bg read and write the Block Editor background setting.
Functionalities:
â
Change Model Space background color.
â
Change Paper Space / Layout background color.
â
Change Block Editor background color.
â
Use global color mode or separate colors per space.
â
Use quick commands for black, white, and grey backgrounds.
â
Toggle black/white background with BGT.
â
Automatically adapt crosshair, AutoTracking vector, and AutoSnap marker colors for contrast.
â
Apply changes live, accept them with OK, or restore the original settings with Cancel.
Result:
đ¨ The drawing display background is updated for the selected spaces.
đī¸ Cursor and drafting marker colors are adjusted to stay visible.
âŠī¸ If the dialog is canceled, the saved color snapshot is restored.
đ§š The temporary DCL file is deleted after the dialog closes.
Images, animations etc.
XAML code:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:Autodesk.Windows;assembly=AdWindows">
<src:RibbonToolTip x:Key="ChangeBackgroundColor">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: BG</Bold>
<LineBreak/>
<Bold>Version: 1 Date: 08.09.2025</Bold>
<LineBreak/>
<LineBreak/>
<Hyperlink>AI+https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-change-background-colour-not-working/td-p/11673817</Hyperlink>
<Hyperlink>AI+https://www.theswamp.org/index.php?topic=47337.0</Hyperlink>
<LineBreak/>
<Bold>Command names</Bold><LineBreak/>
<Run>âĸ BGDCL (type </Run><Run Foreground="DarkRed">BGDCL</Run><Run> at the AutoCAD command line)</Run><LineBreak/>
<Run>âĸ BG (type </Run><Run Foreground="DarkRed">BG</Run><Run> at the AutoCAD command line, alias for BGDCL)</Run><LineBreak/>
<Run>âĸ BGGrey (type </Run><Run Foreground="DarkRed">BGGrey</Run><Run> for quick gray 91,91,91)</Run><LineBreak/>
<Run>âĸ BGWhite (type </Run><Run Foreground="DarkRed">BGWhite</Run><Run> for quick white)</Run><LineBreak/>
<Run>âĸ BGBlack (type </Run><Run Foreground="DarkRed">BGBlack</Run><Run> for quick black)</Run><LineBreak/>
<Run>âĸ bgt (type </Run><Run Foreground="DarkRed">bgt</Run><Run> to toggle Model space background black and white)</Run><LineBreak/>
<LineBreak/>
<Bold>Description</Bold><LineBreak/>
<Run>This program changes AutoCAD display colors by setting the Model space and Paper space background colors, and also sets related UI colors such as crosshair, auto-tracking vector, and autosnap marker color to maintain contrast. It includes a dialog-based UI with Apply and Cancel behavior that can restore the previous settings.</Run><LineBreak/>
<LineBreak/>
<Bold>Main purpose</Bold><LineBreak/>
<Run>âĸ Quickly apply consistent background presets (black, white, and multiple gray shades) without manually editing Options settings.</Run><LineBreak/>
<Run>âĸ Automatically adjust cursor and tracking colors for readability on light or dark backgrounds.</Run><LineBreak/>
<LineBreak/>
<Bold>Prerequisites</Bold><LineBreak/>
<Run>âĸ Requires Visual LISP COM support via </Run><Run Foreground="DarkRed">(vl-load-com)</Run><Run>.</Run><LineBreak/>
<Run>âĸ Uses AutoCAD Preferences objects via ActiveX, so the drawing session must support the Display and Drafting preference interfaces.</Run><LineBreak/>
<Run>âĸ Requires permission to write a temporary DCL file for the dialog created by </Run><Run Foreground="DarkRed">vl-filename-mktemp</Run><Run>.</Run><LineBreak/>
<LineBreak/>
<Bold>User interaction</Bold><LineBreak/>
<Run>âĸ The dialog command </Run><Run Foreground="DarkRed">BGDCL</Run><Run> opens a DCL dialog titled Background Changer.</Run><LineBreak/>
<Run>âĸ The user chooses:</Run><LineBreak/>
<Run> âĸ A preset background color from a dropdown list.</Run><LineBreak/>
<Run> âĸ Where to apply it via toggles:</Run><LineBreak/>
<Run> âĸ <Run Foreground="DarkRed">Model space</Run>.</Run><LineBreak/>
<Run> âĸ <Run Foreground="DarkRed">Paper space</Run>.</Run><LineBreak/>
<Run>âĸ Buttons:</Run><LineBreak/>
<Run> âĸ <Run Foreground="DarkRed">Apply</Run> applies changes but keeps the dialog open.</Run><LineBreak/>
<Run> âĸ <Run Foreground="DarkRed">OK</Run> applies changes and closes the dialog.</Run><LineBreak/>
<Run> âĸ <Run Foreground="DarkRed">Cancel</Run> closes the dialog and restores the pre-dialog snapshot of settings.</Run><LineBreak/>
<LineBreak/>
<Bold>High-level workflow</Bold><LineBreak/>
<Run>âĸ Defines a palette of preset colors (black, white, and several gray values) stored as AutoCAD LONG RGB values.</Run><LineBreak/>
<Run>âĸ On opening the dialog, captures a snapshot of current display and drafting colors so Cancel can revert.</Run><LineBreak/>
<Run>âĸ Writes the dialog DCL source to a temp file and loads it.</Run><LineBreak/>
<Run>âĸ When applying a selection, sets:</Run><LineBreak/>
<Run> âĸ Model background color and Model crosshair color (if Model is enabled).</Run><LineBreak/>
<Run> âĸ Paper background color and Layout crosshair color (if Paper is enabled).</Run><LineBreak/>
<Run> âĸ AutoTracking vector color.</Run><LineBreak/>
<Run> âĸ AutoSnap marker color (changes depending on light or dark background).</Run><LineBreak/>
<Run>âĸ On Cancel, restores all snapshot values (backgrounds, crosshairs, tracking color, and snap marker).</Run><LineBreak/>
<LineBreak/>
<Bold>Functionalities</Bold><LineBreak/>
<Run>âĸ Dialog-based background management with Apply and Cancel restore.</Run><LineBreak/>
<Run>âĸ Preset dropdown supports:</Run><LineBreak/>
<Run> âĸ <Run Foreground="DarkRed">Black</Run> and <Run Foreground="DarkRed">White</Run>.</Run><LineBreak/>
<Run> âĸ Multiple </Run><Run Foreground="DarkRed">gray shades</Run><Run> including Gray 91,91,91 plus additional increments.</Run><LineBreak/>
<Run>âĸ Applies to Model space, Paper space, or both.</Run><LineBreak/>
<Run>âĸ Automatically sets cursor and tracking colors based on background contrast:</Run><LineBreak/>
<Run> âĸ Dark backgrounds get a white crosshair and tracking vector.</Run><LineBreak/>
<Run> âĸ Light backgrounds get a black crosshair and tracking vector.</Run><LineBreak/>
<Run>âĸ Automatically sets AutoSnap marker color:</Run><LineBreak/>
<Run> âĸ Light backgrounds use color 6 (yellow).</Run><LineBreak/>
<Run> âĸ Dark backgrounds use color 2 (red).</Run><LineBreak/>
<LineBreak/>
<Bold>Quick commands</Bold><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">BGGrey</Run> sets both Model and Paper background to Gray 91,91,91 and sets cursor and tracking to white with red autosnap markers.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">BGWhite</Run> sets both backgrounds to white and sets cursor and tracking to black with yellow autosnap markers.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">BGBlack</Run> sets both backgrounds to black and sets cursor and tracking to white with red autosnap markers.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">bgt</Run> toggles Model space background between black and white based on the current Model background value.</Run><LineBreak/>
<LineBreak/>
<Bold>Important commands and calls highlighted</Bold><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">_pref-display</Run> and <Run Foreground="DarkRed">_pref-drafting</Run> â access the Preferences Display and Drafting objects.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">vla-put-GraphicsWinModelBackgrndColor</Run> and <Run Foreground="DarkRed">vla-put-GraphicsWinLayoutBackgrndColor</Run> â set Model and Layout background colors.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">vla-put-ModelCrosshairColor</Run> and <Run Foreground="DarkRed">vla-put-LayoutCrosshairColor</Run> â set crosshair colors.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">vla-put-AutoTrackingVecColor</Run> â sets tracking vector color.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">vla-put-AutoSnapMarkerColor</Run> â sets autosnap marker color.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">_snapshot-current</Run> and <Run Foreground="DarkRed">_restore-snapshot</Run> â snapshot and restore settings for Cancel behavior.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">_apply-bg</Run> â central apply routine that chooses contrast colors and applies changes to Model and Paper.</Run><LineBreak/>
<Run>âĸ <Run Foreground="DarkRed">vl-filename-mktemp</Run> and <Run Foreground="DarkRed">load_dialog</Run> â write and load the temporary DCL UI.</Run><LineBreak/>
<LineBreak/>
<Bold>Outputs and messages</Bold><LineBreak/>
<Run>âĸ If both Model and Paper toggles are off and Apply or OK is pressed: alerts </Run><Run Foreground="DarkRed">Nothing to apply</Run><Run>.</Run><LineBreak/>
<Run>âĸ If the dialog fails to open: alerts </Run><Run Foreground="DarkRed">Failed to open dialog</Run><Run>.</Run><LineBreak/>
<Run>âĸ No explicit success message is printed for Apply or OK; the changes are visible immediately in the graphics window.</Run><LineBreak/>
<LineBreak/>
<Bold>Operational notes and limitations</Bold><LineBreak/>
<Run>âĸ This changes user profile display preferences, not just a single drawing setting, so the effect is global for the current AutoCAD profile and session.</Run><LineBreak/>
<Run>âĸ Cancel restores only the snapshot captured when the dialog opened; if other tools change these preferences while the dialog is open, Cancel will revert them to the snapshot values.</Run><LineBreak/>
<Run>âĸ The bgt command checks only the Model background value to decide black or white toggle behavior.</Run><LineBreak/>
<Run>âĸ AutoSnap marker color is chosen using a threshold based on white intensity; the exact threshold is approximate and may not match every user preference.</Run><LineBreak/>
<Bold><Run Foreground="DodgerBlue">Description</Run></Bold><LineBreak/>
<Run Foreground="White">đ¨ ChangeBackgroundColor is an AutoCAD and Civil 3D AutoLISP utility for changing Model Space, Paper Space, and Block Editor background colors from commands or a DCL dialog.</Run><LineBreak/>
<Run Foreground="LimeGreen">đąī¸ It also adjusts crosshair, AutoTracking vector, and AutoSnap marker colors so the interface remains readable after the background change.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Function Syntax</Run></Bold><LineBreak/>
<Run Foreground="White">đ Command: </Run><Bold><Run Foreground="Orange">BG</Run></Bold><LineBreak/>
<Run Foreground="White">đ Command: </Run><Bold><Run Foreground="Orange">BGDCL</Run></Bold><LineBreak/>
<Run Foreground="White">đ Command: </Run><Bold><Run Foreground="Orange">BGGrey</Run></Bold><LineBreak/>
<Run Foreground="White">đ Command: </Run><Bold><Run Foreground="Orange">BGWhite</Run></Bold><LineBreak/>
<Run Foreground="White">đ Command: </Run><Bold><Run Foreground="Orange">BGBlack</Run></Bold><LineBreak/>
<Run Foreground="White">đ Command: </Run><Bold><Run Foreground="Orange">BGT</Run></Bold><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">SEO Optimized Overview</Run></Bold><LineBreak/>
<Run Foreground="White">đ¨ ChangeBackgroundColor is an SEO-friendly AutoCAD background color manager for CAD users who switch between black, white, grey, and custom workspace visibility setups.</Run><LineBreak/>
<Run Foreground="White">đ§° The BGDCL dialog is created dynamically as a temporary DCL file and lets the user apply one global color or assign different colors to Model Space, Paper Space, and Block Editor.</Run><LineBreak/>
<Run Foreground="White">đī¸ The routine updates display readability by changing crosshair color, AutoTracking vector color, and AutoSnap marker color according to the selected background.</Run><LineBreak/>
<Run Foreground="White">đ§ą Block Editor background is handled through the BEditBackground environment setting using a BGR decimal value, avoiding ARG file patching or registry edits.</Run><LineBreak/>
<Run Foreground="White">âŠī¸ The dialog stores a snapshot of the current colors and restores it if the user cancels.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Key Functionalities</Run></Bold><LineBreak/>
<Run Foreground="White">â
Change Model Space background color.</Run><LineBreak/>
<Run Foreground="White">â
Change Paper Space / Layout background color.</Run><LineBreak/>
<Run Foreground="White">â
Change Block Editor background color.</Run><LineBreak/>
<Run Foreground="White">â
Use global color mode or separate colors per space.</Run><LineBreak/>
<Run Foreground="White">â
Use quick commands for black, white, and grey backgrounds.</Run><LineBreak/>
<Run Foreground="White">â
Toggle black/white background with BGT.</Run><LineBreak/>
<Run Foreground="White">â
Automatically adapt crosshair, AutoTracking vector, and AutoSnap marker colors for contrast.</Run><LineBreak/>
<Run Foreground="White">â
Apply changes live, accept them with OK, or restore the original settings with Cancel.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Important AutoLISP / API Calls</Run></Bold><LineBreak/>
<Run Foreground="White">đ§Š _rgb->long converts RGB values to AutoCAD long color values.</Run><LineBreak/>
<Run Foreground="White">đ§Š _rgb->bgr converts RGB long values to BGR values for BEditBackground.</Run><LineBreak/>
<Run Foreground="White">đ§Š _snapshot-current records Model Space, Paper Space, Block Editor, crosshair, tracking, and AutoSnap colors before dialog changes.</Run><LineBreak/>
<Run Foreground="White">đ§Š _restore-snapshot restores the previous display settings when the dialog is canceled.</Run><LineBreak/>
<Run Foreground="White">đ§Š _apply-space applies selected background colors to the chosen drawing spaces.</Run><LineBreak/>
<Run Foreground="White">đ§Š _bg-dcl-source and _write-dcl-unique generate the temporary DCL interface.</Run><LineBreak/>
<Run Foreground="White">đ§Š _bg-sync-enable enables or disables individual color controls when Global Color is toggled.</Run><LineBreak/>
<Run Foreground="White">đ§Š _be-get-bg and _be-put-bg read and write the Block Editor background setting.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Result</Run></Bold><LineBreak/>
<Run Foreground="White">đ¨ The drawing display background is updated for the selected spaces.</Run><LineBreak/>
<Run Foreground="White">đī¸ Cursor and drafting marker colors are adjusted to stay visible.</Run><LineBreak/>
<Run Foreground="White">âŠī¸ If the dialog is canceled, the saved color snapshot is restored.</Run><LineBreak/>
<Run Foreground="White">đ§š The temporary DCL file is deleted after the dialog closes.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Operational Notes</Run></Bold><LineBreak/>
<Run Foreground="White">âī¸ The routine depends on Visual LISP ActiveX access to AutoCAD Preferences Display and Drafting objects.</Run><LineBreak/>
<Run Foreground="White">đ§ą Block Editor color uses the BEditBackground environment variable and may depend on the AutoCAD version supporting that setting.</Run><LineBreak/>
<Run Foreground="Orange">đ This tool modifies AutoCAD interface preferences, not drawing geometry.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Tags</Run></Bold><LineBreak/>
<Run Foreground="Yellow">đˇī¸ AutoCAD, đˇī¸ AutoLISP, đˇī¸ Civil 3D, đˇī¸ Background Color, đˇī¸ Model Space, đˇī¸ Paper Space, đˇī¸ Block Editor, đˇī¸ DCL Dialog, đˇī¸ CAD UI, đˇī¸ BG</Run><LineBreak/>
</TextBlock>
<Grid>
<Image Source="ChangeBackgroundColor_000.jpg" Stretch="Uniform"/>
</Grid>
<Grid>
<Image Source="ChangeBackgroundColor_001.jpg" Stretch="Uniform"/>
</Grid>
<Grid>
<MediaElement
Source="GIF"
Stretch="Uniform"
Visibility="Visible"/>
</Grid>
</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>
