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¶
Check for Existing Panels/Sites
If current drawing has panels or sites: Offer as template
Template Selection Dialog
Show
dwg.dcldialogPresent options: Use current, select template, or start from scratch
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
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
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 templatetempsite.dwg- Site template
Global Variables¶
Input:
pnl- User action (“old”, “new”, “cancel”, “np”)curdir- Current project directoryolddir- Source project directorydwg- Selected template filenameolddwg- Temporary template filename
Output:
ld- Load mode (“ps”, “ss”, “pt”, “st”)wcl- Merged weld connection listwcxn- Maximum weld connection ID
Detects:
panel_list- Named object dictionary entrysite_list- Named object dictionary entry
Load Modes¶
Mode |
Meaning |
Context |
|---|---|---|
|
Panel Set |
New panel from template |
|
Site Set |
New site from template |
|
Panel Template |
Blank panel drawing |
|
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