Function Syntax: NEWLAYERCLI / LayerCreation Version: 1.1 Date: 20.06.2026 6:38:53PM AI+ LayerCreation.LSP — Operational Summary This program creates or updates an AutoCAD layer and optionally sets it as the current layer, while also setting default variables for newly created objects. It does not require the user to select blocks or entities. How the User Runs It Available commands: LayerCreation — preferred entry point; uses a DCL dialog when DCL core functions are available. NEWLAYERCLI — command-line fallback that always works and supports the same key inputs. What the Program Does Core objective: • Create a new layer if it does not exist, or update it if it already exists. • Apply user-specified properties: Color (ACI or RGB or Color Book), Linetype, Lineweight, and Transparency. • Optionally set the created/updated layer as the current layer. • Set drawing defaults for new objects (system variables) such as linetype scale and thickness. User Inputs and Prompts LayerCreation (DCL dialog path): • Layer name (edit box). • Color entry as text (supports): ACI like 7. RGB like 255,255,255. Color Book token like BOOK$COLORNAME (picked via dialog). • Color picker button Pick... to open the true color dialog (including color books when available). • Linetype selection (popup list). • Lineweight selection (popup list). • Transparency value in range 0 to 90. • Toggle: Set as current layer (default checked). • Defaults for new objects: CELTSCALE (default 0.05). THICKNESS (default 0). NEWLAYERCLI (command line path): • Prompts for layer name until valid. • Color prompt supports Pick (default) using true color dialog and color books when available. • Prompts for transparency, CELTSCALE, thickness, set-current Yes or No. • Prompts for linetype index and lineweight index from enumerated lists. Primary Functionalities (Bullet Summary) Validates layer names and blocks illegal characters: • Disallows backslash, slash, colon, semicolon, asterisk, question mark, quotes, angle brackets, pipe, comma, equals. Creates or updates a layer using AutoCAD command calls: • Uses -LAYER to create the layer and set linetype, lineweight, and transparency. Loads linetypes on demand if a chosen linetype is not already in the drawing: • Uses -LINETYPE Load from acad.lin. Applies color using TrueColor so it can support: • Index colors (ACI). • TrueColor RGB. • Color book colors via SetColorBookColor. Optionally sets the created layer current by setting CLAYER. Sets drawing defaults for new objects using safe setvar calls that do not abort the routine if a variable is rejected: • CELTSCALE, CETRANSPARENCY, THICKNESS. Provides a resilient UI strategy: • Detects whether DCL core functions are healthy and automatically falls back to CLI if not. • Builds a temporary DCL file in TEMPPREFIX at runtime and deletes it after closing the dialog. Persists last-used color so the next run starts from the prior selection. Key Commands and Internal Helpers (Highlighted) Main commands: C:LayerCreation — runs dialog if DCL is available, otherwise routes to CLI. C:NEWLAYERCLI — always-available command-line workflow. Important AutoCAD command calls: .-LAYER — New, Ltype, LWeight, TRansparency actions. .-LINETYPE — Load linetype if missing. Important dialogs: acad_truecolordlg — preferred color picker (truecolor and color books). acad_colordlg — fallback color picker (ACI). Key helper routines: NL:_illegalLayerNameP — validates layer names. NL:_getLinetypes — enumerates linetypes from the drawing table. NL:_applyColorToLayer — applies ACI or RGB or color book via VLA TrueColor. NL:_setvarSafe — safe system-variable setter that traps errors. Outputs and Side Effects Creates or updates one layer in the current drawing session and changes properties immediately. Optionally sets CLAYER to the created or updated layer. Sets or attempts to set these variables for subsequent newly created objects: CELTSCALE default 0.05. CETRANSPARENCY default from chosen transparency (0-90). THICKNESS default 0. Important Notes and Constraints • If DCL is not operational, the program automatically runs NEWLAYERCLI and continues without failure. • The dialog is generated dynamically to a temporary DCL file and removed after use. • Color text can be manually typed; the program parses ACI, RGB, or book tokens and applies the corresponding color method. • Transparency is clamped to a safe range (0-90) before being applied. • Linetype is ensured to be loaded before being assigned to the layer. • Uses COM via vl-load-com and VLA objects for TrueColor application. Description 🧱 LayerCreation is an AutoCAD and Civil 3D AutoLISP tool for creating or updating layers with color, linetype, lineweight, transparency, and default object settings. 🎨 It supports ACI colors, RGB true color, color books, a DCL dialog, and a reliable command-line fallback. Function Syntax 🚀 Main command: LayerCreation ⌨️ Command-line fallback: NEWLAYERCLI 🎨 Layer fields: Name, Color, Linetype, Lineweight, Transparency. ⚙️ New object defaults: CELTSCALE, CETRANSPARENCY, THICKNESS, and Set as current layer. SEO Optimized Overview 🧱 LayerCreation is an SEO-friendly AutoCAD layer creation and layer-standard utility for building or updating drawing layers with consistent properties. 🎨 The routine supports standard ACI colors, RGB true-color values, and color book selections, making it more flexible than a simple layer-name macro. 📐 It lets the user define linetype, lineweight, transparency, CELTSCALE, CETRANSPARENCY, THICKNESS, and whether the new layer should become current. 🧠 The dialog path uses dynamically generated DCL, while NEWLAYERCLI provides a command-line fallback if DCL is not healthy in the AutoCAD session. 📌 This is useful for CAD standards, Civil 3D layer setup, project templates, repeated layer creation, and controlled drawing initialization. Primary Workflow 1️⃣ Load the AutoLISP file in AutoCAD or Civil 3D with APPLOAD or your menu loader. 2️⃣ Run the command shown above from the AutoCAD command line. 3️⃣ Follow the dialog, selection prompts, or file prompts used by LayerCreation. 4️⃣ Review the command-line report and drawing result before continuing production work. Functionalities ✅ Create a new AutoCAD layer by name. ✅ Update an existing layer with new display and plotting properties. ✅ Select ACI, RGB true color, or color book color information. ✅ Choose linetype and lineweight from drawing data. ✅ Clamp transparency values to a safe range. ✅ Set the new or updated layer current when required. ✅ Apply object-default variables for new entities. ✅ Fall back to NEWLAYERCLI when the DCL core is unavailable. Important Functions and AutoCAD API 🧩 NL:_illegalLayerNameP validates layer names against AutoCAD-invalid characters. 🧩 NL:_getLinetypes reads available linetypes for the dialog list. 🧩 NL:_pickColor launches AutoCAD color selection and stores ACI, RGB, or color book information. 🧩 NL:_applyColorToLayer applies ACI, true color, or color book selections to the layer object. 🧩 NL:_makeOrUpdateLayer creates a new layer or updates the existing layer with selected properties. 🧩 NL:_applyDefaultsAndMaybeSetCurrent applies CELTSCALE, CETRANSPARENCY, THICKNESS, and CLAYER behavior. 🧩 NL:_runDialog builds and runs the DCL interface. Result 🎯 The result is a correctly created or updated AutoCAD layer with the desired CAD-standard properties. 🟢 The user gets a direct message confirming the layer name that was created or updated. Operational Notes and Limitations ⚠️ The command can overwrite properties of an existing layer with the same name. ⚠️ Invalid layer-name characters are rejected to avoid AutoCAD table errors. 🧠 The true color and color book behavior depends on AutoCAD's ActiveX color object support. Tags 🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Civil 3D, 🏷️ Layer Creation, 🏷️ True Color, 🏷️ Color Books, 🏷️ Linetype, 🏷️ Lineweight, 🏷️ DCL Dialog