ChangeBackgroundColor

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.

Pixel

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-&gt;long converts RGB values to AutoCAD long color values.</Run><LineBreak/>
<Run Foreground="White">🧩 _rgb-&gt;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>



Share this page:

Tags: đŸˇī¸ AutoCAD, đŸˇī¸ AutoLISP, đŸˇī¸ Background Color, đŸˇī¸ BG, đŸˇī¸ Block Editor, đŸˇī¸ CAD UI, đŸˇī¸ Civil 3D, đŸˇī¸ DCL Dialog, đŸˇī¸ Model Space, đŸˇī¸ Paper Space