PANEL.lsp — Panel Entry Point & Validation¶
Module: panel.lsp
Version: v3.60
Category: Panel Drawing & Layout
Complexity: High
Size: 4.3 KB (99 lines)
Note
Panel Workflow Controller
This is the main entry point for panel creation and editing. It validates drawing compatibility, checks for existing panel data, and routes to the appropriate dialog or batch processing.
Overview¶
Purpose¶
The panel function is the primary entry point for panel operations. It validates that the current drawing is compatible with the project, checks for existing panel data in the drawing database, and either displays the mix profile dialog or processes batch operations.
Algorithm¶
Initialize Environment
Call
(setvars)to establish AutoCAD environment
Batch vs Interactive Check
If batch mode: Skip dialog, call
(panatt)directlyIf interactive: Continue with validation
Extract Drawing Identifiers
Get panel_list data from named object dictionary
Get drawing filename (without .dwg extension)
Search for TITLE block and extract FILE attribute
Search for NUM block and extract P# attribute
Compatibility Validation
Compare panel_list data vs. title block data
Check if drawing filename matches project name pattern
Determine if drawing is compatible for editing
Route to Appropriate Action
No panel_list: New panel ?
(mp_dlg)Compatible drawing: Edit panel ?
(mp_dlg)New panel flag set: New panel ?
(mp_dlg)Incompatible: Alert user, return to menu
Process Panel Data (if ok = “ok”)
Build xrecord from panelvar
Delete existing panel_list entry
Create new panel_list entry
Call
(drawpan)to generate drawing
Key Features¶
Drawing Compatibility Check¶
Identifiers Compared:
a- Panel ID from panel_listb- Panel number from NUM block (P# attribute)c- Drawing filename (without .dwg)d- Filename from TITLE block (FILE attribute)
Compatible If:
(and (wcmatch c (strcat "*" pnlname "*")) ; Filename matches project
(or (and (= a b) (= c d)) ; IDs match
(and a (not b)) ; Has list, no block
(and c (not d)))) ; Has filename, no title
Version-Specific Dictionary Access¶
AutoCAD Version Detection:
(if (< (distof (getvar "acadver")) 15)
(set 'n 19) ; R14: Use index 19
(set 'n 21)) ; 2000+: Use index 21
Purpose: Dictionary structure differs between AutoCAD versions.
Named Object Dictionary Structure¶
panel_list xrecord:
(0 . "xrecord")
(100 . "AcDbXrecord")
(1 . "group_name") ; Panel variable group
(2 . "control_name") ; Control identifier
(3 . "value") ; Control value
...
Block Search Logic¶
TITLE Block¶
Search:
(ssget "x" '((-4 . "<and") (0 . "INSERT") (2 . "TITLE") (-4 . "and>")))
Extract FILE Attribute:
Iterate through block attributes
Find attribute with tag “FILE”
Store value in
d
NUM Block¶
Search:
(ssget "x" '((-4 . "<and") (0 . "INSERT") (2 . "NUM") (-4 . "and>")))
Extract P# Attribute:
Iterate through block attributes
Find attribute with tag “P#” or “101”
Store value in
b
Batch Processing¶
Batch Modes (btchp):
1,3,5,7,9- Interactive modes (show dialog)Other values - Batch mode (skip dialog)
Batch Behavior:
Set
ok= “ok”Call
(panatt)directlySkip
(mp_dlg)dialog
Panel Data Structure¶
panelvar Format¶
Structure:
(
("group1" . (("ctrl1" . "val1") ("ctrl2" . "val2")))
("group2" . (("ctrl3" . "val3") ("ctrl4" . "val4")))
...
)
Conversion to xrecord:
(1 . "group1")
(2 . "ctrl1")
(3 . "val1")
(2 . "ctrl2")
(3 . "val2")
(1 . "group2")
...
Version Stamp¶
Added to xrecord:
(set 'mpv# "V3.60")
Purpose: Identify panels created with v3.60 for compatibility checking.
Error Messages¶
Incompatible Drawing¶
Alert:
"This Drawing Database has been modified in a way that makes it
incompatible for editing in this Project.
However, it can still be used as a Template to create a New Drawing."
Triggers:
Drawing has panel data
Panel IDs don’t match
Filename doesn’t match project pattern
Not a new panel
Recovery: Return to menu (pnl = “md”)
Global Variables¶
Input:
btchp,btch#- Batch processing flagsnewpan- New panel flag (“new”)pnlname- Project name prefixpanelvar- Panel variable structureok- Dialog result
Output:
mpv#- Version stamp (“V3.60”)xrec- xrecord for named object dictionary
Modified:
panelvar- Updated with current values
Document Metadata¶
Status: Comprehensive analysis
Last Updated: 2026-01-20
Analysis Method: Source code review + AutoCAD entity analysis
End of Document