I could really use your help! I am not a lisp guy at all but can read them for the most part. I am really lost trying to figure out where this lsp is pulling the names of the layout to plot.
Let me explain how this is supposed to work....
The user is asked if this is a prelim or final set they want to plot. If they say Prelim, it only is to plot certain layouts (4 of the 21 existing layouts). It will then purge the drawing, bind xrefs, and plot to a specific directory.
If it is a final it does the same but plots all the layouts.
We have since added new layouts and need some of them to plot in prelim. For the life of me I cannot see where that list of layouts is defined!! IS there a way I can manually put into the code which layouts, by name, to plot??
This is what it looks like.........
(defun DoBind ( / StateName )
(command "undo" "begin")
(command "model")
(command "zoom" "e")
(command "tilemode" 0)
(command "zoom" "e")
(command "-xref" "r" "*")
(command "-xref" "b" "*")
; If Prelim, delete unnecessary sheets. If Final, skip this part
(if (= request "P")
(progn
(setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
; For every layout tab in the drawing...
(vlax-for x (vla-get-layouts acdoc)
; ...make a new list item from the layout's tab number
; and name then add it to a list of such items
(setq layouts (cons (cons (vla-get-taborder x) (vla-get-name x)) layouts))
)
; Sort the layouts list by the first element of
; each item (tab order) and save into new list
; called lbto (layouts by tab order)
(setq lbto
(cdr
(mapcar 'cdr
(vl-sort layouts
(function (lambda (x y) (< (car x) (car y))))
)
)
)
)
; Make a new list of layouts from AD1 and after
(setq delsheets (member "AD1" lbto))
; Delete each layout in the new list
(foreach sheet delsheets
(command "_.layout" "Delete" sheet)
)
)
)
; Purge after all other commands are done
(vla-purgeall (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-purgeall (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-purgeall (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-purgeall (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-purgeall (vla-get-ActiveDocument (vlax-get-acad-object)))
(command "undo" "end")
; If bound version already exists, this handles the file dialog for the user
(if (= exist 1)
(progn
(setvar "filedia" 0)
(command "saveas" "" savename "y")
(setvar "filedia" 1)
)
(progn
(vl-mkdir bindpath)
(setvar "filedia" 0)
(command "saveas" "" savename)
(setvar "filedia" 1)
)
)
)
;; Do Not Bind subfunction
(defun DoNotBind ( / )
(alert "Drawing not bound")
)
;; Main Function
(defun C:pbp ( / bindpath savename overwrite exist request)
;Commands in silent mode.
(setq oldosmode (getvar "osmode"))
(setq oldcmdecho (getvar "cmdecho"))
(setq oldnomutt (getvar "nomutt"))
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(setvar "nomutt" 0)
; Ask if Prelim or Final
(initget "P F")
(setq request (getkword "\nRequest type [Prelim/Final]: "))
; Construct the path to deliverables folder from active drawing's path
(setq bindpath (vl-string-subst "\\Deliverables\\" "\\Drawings\\" (getvar "dwgprefix")))
; Combine deliverables path with current filename to see if already exists
(setq savename (strcat bindpath (vl-filename-base (getvar "dwgname"))))
; If bound version already exists, prompt to overwrite it or not
(if (findfile (strcat savename ".dwg"))
(progn
(setq exist 1)
(initget "Y N")
(setq overwrite (getkword "\nDeliverables already exist - Overwrite? [Yes/No]: <N>"))
(if (= overwrite "Y")
(DoBind) (DoNotBind)
)
)
; If no bound version exists, create one
(DoBind)
)
; Export to PDF (skip if user chose not to overwrite existing files)
(setvar "filedia" 0)
(setvar "nomutt" 1)
(if (= exist 1)
(if (= overwrite "Y")
(command "-export"
"p"
"a"
savename
"y"
)
)
(command "-export"
"p"
"a"
savename
)
)
(setvar "filedia" 1)
;Reset to original "osmode" and "cmdecho".
(setvar "osmode" oldosmode)
(setvar "cmdecho" oldcmdecho)
(setvar "nomutt" oldnomutt)
(princ)
(princ)
)