Function Syntax: LayerCreation Version: 1 Date: 14.12.2025 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.