creating lisp routine to setup new drawing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi all,
seeking some help regarding a lisp routine. Basically, I have created a template file for creating our drawing sheets. In this template are several layout tabs that houses the titleblock attributes associated with the layout style eg a1 horizontal, a1 vertical etc. I want this routine when ran to open a dialog box that prompts to select the template file, when selected a list of the layouts appears below, when the layout is selected a new drawing is created with that layout and the other unneeded layouts are deleted. IE I click the a1 horizontal, it uses the template to create a new drawing with the horizontal layout and attributes and deletes the other tabs.
I have created a lisp routine below that works in conjunction with a dcl file, but the lisp fails after selecting the template, it does not bring up a list of the layouts.
See below:
Lisp:
(defun c:CreateNewSheet ()
(setq templatePath (getfiled "Select Template" "" "dwt" 1)) ; Prompt user to select template file
(if (null templatePath)
(exit)
)
(setq dialog (load_dialog "CreateNewSheet.dcl")) ; Load the dialog box
(if (not dialog)
(progn
(alert "Failed to load dialog box.")
(exit)
)
)
(if (not (new_dialog "CreateNewSheet" dialog)) ; Display the dialog box
(progn
(alert "Failed to display dialog box.")
(unload_dialog "CreateNewSheet" dialog) ; Unload the dialog box if failed to display
(exit)
)
)
(set_tile "template" templatePath) ; Set default template path in the dialog
(setq layoutTabsList (list "A1 Horizontal" "A1 Vertical")) ; Example list of layout tabs, replace with actual list
(foreach tab layoutTabsList
(start_list "layoutTabs")
(add_list tab)
)
(start_dialog) ; Start the dialog loop
(unload_dialog "CreateNewSheet" dialog) ; Unload the dialog box
)
(defun c:CreateSheetOK () ; Function to be called when OK button is pressed
(setq selectedTemplate (get_tile "template")) ; Get selected template path
; Get selected layout tab
(setq selectedLayout (get_tile "layoutTabs"))
; Perform necessary actions with selectedTemplate and selectedLayout
(princ (strcat "Selected Template: " selectedTemplate "\n"))
(princ (strcat "Selected Layout: " selectedLayout "\n"))
; Close dialog
(done_dialog 1)
)
(defun c:CreateSheetCancel () ; Function to be called when Cancel button is pressed
(done_dialog 0) ; Close the dialog box
)
DCL:
// CreateNewSheet.dcl
createNewSheet : dialog {
label = "Create New Sheet";
: row {
: static_text { label = "Select Template:"; }
: edit_box { key = "template"; width = 30; }
: browse_button { label = "Browse..."; }
}
: row {
: list_box { key = "layoutTabs"; width = 30; }
}
: row {
: button { key = "ok"; label = "OK"; is_default = true; action = "(c:CreateSheetOK)"; }
: button { key = "cancel"; label = "Cancel"; is_cancel = true; action = "(c:CreateSheetCancel)"; }
}
}
Note that essentially I want it to work similiar to the sheetset in when you create a new sheet it brings up the prompts like seen in screenshot. However we are updating attributes using an excel sheet, so I don't need it to prompt for the name of file and so on if that makes sense
any help is appreciated.