DWGNEW.lsp — New Drawing Template Selection

Module: dwgnew.lsp
Version: v3.60
Category: Project Management
Complexity: High
Size: 8.2 KB (159 lines)

Note

Template Drawing Management

This complex module handles template drawing selection for new drawings, supporting both same-project templates and cross-project imports. It manages weld connection definition migration and creates temporary template files.


Overview

Purpose

The dwgnew function manages template drawing selection when creating new drawings. It can use the current drawing, select from the same project, or import from another project with intelligent weld connection merging.

Algorithm

  1. Check for Existing Panels/Sites

    • If current drawing has panels or sites: Offer as template

  2. Template Selection Dialog

    • Show dwg.dcl dialog

    • Present options: Use current, select template, or start from scratch

  3. Template Source Options:

    • Current Drawing: Save as temp template (temp.dwg or tempsite.dwg)

    • Same Project: Select .dwg file

    • Different Project: Import with weld connection merge

  4. Cross-Project Import Logic:

    • Load weld connections from source project (olddir/wcl.txt)

    • Load weld connections from destination project (curdir/wcl.txt)

    • Merge lists (preserving existing IDs)

    • Write merged list to source project

    • Copy template file

    • Alert user about weld connection import

  5. Drawing Type Detection:

    • Filename contains “SITE”: Set ld = “ss” (site)

    • Otherwise: Set ld = “ps” (panel)


Key Features

Cross-Project Template Import

Weld Connection Merge:

; Load source wcl.txt
; Load destination wcl.txt
; Merge: Keep existing IDs, add new ones
; Write merged list back

User Alert:

"You have chosen a drawing from a different Project to use as a Template.
To maintain Panel integrity, ConstructiVision will now attempt to import the
Weld Connection definitions used in that Project. However, existing Weld Connections
in your current Project with the same internal ID number will NOT be overwritten.
You should verify all Weld Connections in your new Panel."

Version-Specific Save Format

AutoCAD Version Detection:

(if (< (distof (getvar "acadver")) 15)
  (command "saveas" "r14" filename)    ; R14 format
  (command "saveas" "2000" filename))  ; 2000+ format

Template File Naming

Temporary Files:

  • temp.dwg - Panel template

  • tempsite.dwg - Site template


Global Variables

Input:

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

  • curdir - Current project directory

  • olddir - Source project directory

  • dwg - Selected template filename

  • olddwg - Temporary template filename

Output:

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

  • wcl - Merged weld connection list

  • wcxn - Maximum weld connection ID

Detects:

  • panel_list - Named object dictionary entry

  • site_list - Named object dictionary entry


Load Modes

Mode

Meaning

Context

ps

Panel Set

New panel from template

ss

Site Set

New site from template

pt

Panel Template

Blank panel drawing

st

Site Template

Blank site drawing


Weld Connection List Structure

Format:

(ID "Name" Width Height Y-Offset ...)

Example:

(0 " " 0.0 0.0 0.0 "" "" "" "" "" "" "" 0.0 0.0)
(1 "Embed1" 3.0 4.0 1.5 ...)

ID 0: Always reserved as placeholder/default



Document Metadata

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


End of Document