Can I specify which layout to plot?

Can I specify which layout to plot?

jim.lawRPHLY
Contributor Contributor
1,360 Views
29 Replies
Message 1 of 30

Can I specify which layout to plot?

jim.lawRPHLY
Contributor
Contributor
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)
)
0 Likes
Accepted solutions (1)
1,361 Views
29 Replies
Replies (29)
Message 21 of 30

paullimapa
Mentor
Mentor

I did not change the last section of your code that exports all layouts to pdf:

; 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)
 

you can actually follow the sequence by entering those commands at the command prompt and it's suppose to Export pdf for all layouts:

paullimapa_0-1743620437909.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 22 of 30

jim.lawRPHLY
Contributor
Contributor

OK, something makes NO SENSE! The drawing with the 5 layout I want only exports the first 3 using the export pdf command, no lisp involved!!

I have no explanation for that!

0 Likes
Message 23 of 30

paullimapa
Mentor
Mentor

Since you added those additional layouts maybe you forgot to assign a page setup to them like the other layouts already have.

Just select one of the other previously already made layouts like CS so that it becomes current, right mouse click on it, select Page Setup Manager and it'll show you the pages setup name. Then click on each of the R-A1 layouts making them current and do the same to assign them with the matching page setup name.

paullimapa_0-1743624038089.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 24 of 30

jim.lawRPHLY
Contributor
Contributor

The "R" sheets are 11x17 and have the appropriate page setup assigned to them. The others are 36x24 and have their page setups

0 Likes
Message 25 of 30

paullimapa
Mentor
Mentor

as a test move the R sheets to the front

as another test change the R sheets to the 36x24 page setup and now see if they export

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 26 of 30

baksconstructor
Advocate
Advocate

Why ????
Doesn't the steps described seem too wrong to you?
It can all be done more simply.
You created a drawing.
Pressed the button - got all the necessary tabs for printing, - for preliminary printing - deleted unnecessary ones in the print table, printed.
- for final printing - pressed the button - got printing of all.
Your lisp does not fully correspond to your task.
Use a different work algorithm and other work methods.
Take paper and pencil, and write down the stages of your work and you will understand your mistake.

0 Likes
Message 27 of 30

jim.lawRPHLY
Contributor
Contributor

WHY? you ask? Because the powers that be want this thing fixed. They want a "one pick" dose everything command. I personally think the concept is good, but this command could be written better for sure. Again, I do not know how to write lips so I did not create it.

 

@paullimapa and @baksconstructor and all of you on here, how hard would it be for someone to write a command that makes it easy to specify which layout to use for prelim prints so that anyone, without lisp experience can update it??

0 Likes
Message 28 of 30

Sea-Haven
Mentor
Mentor

I did another version of the plot range which looks at each layout title block and sets the correct plot parameters, so you can have a mix of sheet sizes.

 

Ok its not free but real cheap, I have to set the sheet size values  for your title blocks, yes you could do it but I dont want the repeated something not right posted here. Let me know and we can discuss further.

0 Likes
Message 29 of 30

baksconstructor
Advocate
Advocate
Accepted solution

@paullimapa and @baksconstructor and all of you on here, how hard would it be for someone to write a command that makes it easy to specify which layout to use for prelim prints so that anyone, without lisp experience can update it??



Since the administrator forbids sharing links on this forum, I can't give it to you.
The administrator has forbidden me from sharing information with you.
If you need a solution, write me a private message.

0 Likes
Message 30 of 30

Sea-Haven
Mentor
Mentor

"how hard would it be for someone to write a command that makes it easy to specify which layout to use" that is what my plotrange does just that plot a range of layouts from 1 layout, a range start->end, 1 to 3,  to all. 

SeaHaven_0-1744069760289.png

 

0 Likes