DWGOLD.lsp — Existing Drawing Selection

Module: dwgold.lsp
Version: v3.60
Category: Project Management
Complexity: Medium
Size: 2.8 KB (63 lines)

Note

Drawing File Selector

This module handles the selection and opening of existing drawings, automatically detecting whether the drawing contains panels or sites and setting the appropriate load mode.


Overview

Purpose

The dwgold function manages the selection and opening of existing project drawings. It presents a dialog if the current drawing already has panels/sites, validates the selection, detects drawing type (panel vs. site), and sets the appropriate load mode.

Algorithm

  1. Check Current Drawing

    • If has panels or sites: Show “dwg” dialog

    • Message: “Do you want to edit this drawing or select another one?”

    • Note: Warns about closing current project

  2. Auto-Detect Drawing Type

    • If not switching drawings and current has content:

      • site_list exists: Set ld = “st”

      • panel_list exists: Set ld = “pt”

  3. File Selection (if switching)

    • Default to “Project Files\” directory

    • File dialog: “Choose a drawing to edit.”

    • Validate directory via (dirchk)

  4. Extract Path & Detect Type

    • Parse selected path for directory and filename

    • Filename contains “SITE”: ld = “ss”

    • Otherwise: ld = “ps”

  5. Cancel Handling

    • Set pnl = “md” (menu display)


Key Features

Drawing Type Detection

Detection Rules:

(if (wcmatch (strcase dwg) "*SITE*")
  (set 'ld "ss")    ; Site drawing
  (set 'ld "ps"))   ; Panel drawing

Load Modes:

  • st - Site Template (current drawing has sites)

  • pt - Panel Template (current drawing has panels)

  • ss - Site Set (selected drawing is site)

  • ps - Panel Set (selected drawing is panel)

Project Switching Warning

Message:

"Note: Selecting a drawing from a different Project will
automatically close your current Project."

Purpose: Alert user that changing projects will close current work.


Global Variables

Input:

  • pnl - User action (“old”, “cancel”)

  • curdir - Current directory

  • dwg - Current/selected drawing filename

  • acaddir - AutoCAD installation directory

Output:

  • curdir - Selected drawing directory

  • dwg - Selected drawing filename

  • ld - Load mode (pt, st, ps, ss)

  • pnl - Set to “md” if cancelled

Detects:

  • panel_list - Named object dictionary entry

  • site_list - Named object dictionary entry


Dialog Messages

Edit vs. Select Dialog

Message Variables:

  • msg - “Do you want to edit this drawing or select another one?”

  • msg1 - Warning about closing current project

  • msg2 - “ “ (blank)

Help Context: “do”



Document Metadata

Status: Comprehensive analysis
Last Updated: 2026-01-20


End of Document