Sambuddy Posted May 25, 2020 Posted May 25, 2020 (edited) I had a problem in the past whereby the first page appeared blank and I pulled out my hair to fix it - now that this problem is over I am back to yet give it another try to see if I can make this routine successful. Upon entering "PUB" command I would have three options (1st one uses autopub) (second is the one with the problem) (3rd only sets the correct page setup). I tried to use ghostscript but with no success - I then jupmed in to use another application as shell command (PDFTK builder) but that did not panout either. I would like basically the "PDF-SELECTION" option to select page setup, then select layout, then create and combine PDF. shout out to LEE MAC, BIGAL, ROY_43 for their earlier responses and helping me get started. the question is: how can I combine single PDFs with their correct layout names into one pdf file with the project name? I read about the discussions on this platform between @Roy_043 and @BIGAL but could not make the combined pdf. Please help! Thanks (defun c:PUB () (c:CDI) (c:PUB-MENU-OPTION) (princ) ) ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; SET-PG-LAY ==> SETS PAGE LAYOUT FOR ALL TABS ;; ;; LM:listfort ==> LEE MAC LISTBOX DCL ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; (defun c:SET-PG-LAY ( / col doc itm lst ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) col (vla-get-plotconfigurations doc) ) (cond ( (zerop (vla-get-count col)) (princ "\nNo Page Setups found.") ) ( (null (setq itm (LM:listfort "Select Page Setup to Apply" (progn (vlax-for x col (setq lst (cons (vla-get-name x) lst))) (acad_strlsort lst) ) 0 ) ) ) (princ "\n*Cancel*") ) ( (setq itm (vla-item col (car itm))) (vlax-for x (vla-get-layouts doc) (if (/= "MODEL" (strcase (vla-get-name x))) (vla-copyfrom x itm) ) ) ) ) (princ) ) ;END DEFUN ;; List Box - Lee Mac ;; Displays a DCL list box allowing the user to make a selection from the supplied data. ;; msg - [str] Dialog label ;; lst - [lst] List of strings to display ;; bit - [int] 1=allow multiple; 2=return indexes ;; Returns: [lst] List of selected items/indexes, else nil (defun LM:listfort ( msg lst bit / dch des tmp rtn ) (cond ( (not (and (setq tmp (vl-filename-mktemp nil nil ".dcl")) (setq des (open tmp "w")) (write-line (strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select=" (if (= 1 (logand 1 bit)) "true" "false") ";width=36;height=52;}spacer;ok_cancel;}" ) des ) (not (close des)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch) ) ) (prompt "\nError Loading List Box Dialog.") ) ( t (start_list "list") (foreach itm lst (add_list itm)) (end_list) (setq rtn (set_tile "list" "0")) (action_tile "list" "(setq rtn $value)") (setq rtn (if (= 1 (start_dialog)) (if (= 2 (logand 2 bit)) (read (strcat "(" rtn ")")) (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")"))) ) ) ) ) ) (if (< 0 dch) (unload_dialog dch) ) (if (and tmp (setq tmp (findfile tmp))) (vl-file-delete tmp) ) rtn ) (vl-load-com) (princ) ;;------------------------------------------------------------------------------------------------------------------------------------------------------------------;; ;; END OF ;; ;; [SET-PG-LAY] ;; ;;------------------------------------------------------------------------------------------------------------------------------------------------------------------;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; ^[PUBLISH-LIST-LAYOUT-PDF]^ ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; PUBLISH-LIST-LAYOUT-PDF ==> PLOT TABS ;; ;; LM:FiltListBox ==> LEE MAC LISTBOX DCL & IGAL AVERBUH ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; (defun c:PUBLISH-LIST-LAYOUT-PDF ( / itm lst BACKGROUNDPLT ) (setq BACKGROUNDPLT (getvar 'BACKGROUNDPLOT)) (setvar "BACKGROUNDPLOT" 0) (setvar 'TRAYTIMEOUT 1) (setq lst (LM:FiltListBox "Select Layouts to Plot" (layoutlist) T )) (foreach itm lst ;; For every 'itm' in the list given by 'lst' (setvar 'LTSCALE 1) (setvar 'PSLTSCALE 0) (setvar 'CTab itm) (setq pdfmergedfilename (getvar "dwgname")) (setq pdfsinglefileloc (strcat "C:\\Temp\\PDF\\"(getvar "Ctab"))) (command "-PLOT" "N" "" "" "" pdfsinglefileloc "N" "Y") (princ (strcat "\nPlotting Layout \"" itm "\" " )) ) ;; end foreach (if (= (getvar "tilemode") 0) (setvar "tilemode" 1)) ; Go back to MSPACE ; make a batch file ? ;gs -sDEVICE=pdfwrite \ ; -dNOPAUSE -dBATCH -dSAFER \ ; -sOutputFile=combined.pdf \ ; first.pdf \ ; second.pdf \ ; third.pdf [...] ;Ghostscript (http://www.ghostscript.com/) can be used to combine PDFs. ; Something like this should work: by Roy_043 (defun KGA_String_Join (strLst delim) (if strLst (apply 'strcat (cons (car strLst) (mapcar '(lambda (a) (strcat delim a)) (cdr strLst)) ) ) "" ) ) (CombinePdf (setq gsexe "C:\\Program Files\\gs\\gs9.50\\bin\\gswin64c") (setq srcFileLst '("C:\\Temp\\*.pdf")) (setq trgfile "C:\\Acadtemp\\Total.pdf") ) ; Note: Existing trgFile will be overwritten. (defun CombinePdf (gsExe srcFileLst trgFile) (startapp (strcat gsExe " " "-sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dQUIET " "-sOutputFile=\"" trgFile "\" " "\"" (KGA_String_Join srcFileLst "\" \"") "\"" ) ) ) (princ) ) ;END DEDUN ;;------------------------------------------------------------------------------------------------------------------------------------------------------------------;; ;; END OF ;; ;; [PUBLISH-LIST-LAYOUT-PDF] ;; ;;------------------------------------------------------------------------------------------------------------------------------------------------------------------;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; ^[PUBLISH-LIST-LAYOUT-PLOT]^ ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; PUBLISH-LIST-LAYOUT-PLOT ==> PLOT TABS ;; ;; LM:FiltListBox ==> LEE MAC LISTBOX DCL & IGAL AVERBUH ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; (defun c:PUBLISH-LIST-LAYOUT-PLOT ( / itm lst BACKGROUNDPLT ) (setq BACKGROUNDPLT (getvar 'BACKGROUNDPLOT)) (setvar "BACKGROUNDPLOT" 0) (setvar 'TRAYTIMEOUT 1) (setq lst (LM:FiltListBox "Select Layouts to Plot" (layoutlist) T )) (foreach itm lst ;; For every 'itm' in the list given by 'lst' (setvar 'LTSCALE 1) (setvar 'PSLTSCALE 0) (setvar 'CTab itm) (COMMAND "-PLOT" "N" "" "" "" "" "N" "Y") (princ (strcat "\nPlotting Layout \"" itm "\" " )) ) ;; end foreach (if (= (getvar "tilemode") 0) (setvar "tilemode" 1)) ; Go back to MSPACE (princ) ) ;END DEDUN ;;------------------=={ Filtered List Box }==-----------------;; ;; ;; ;; Displays a list box interface from which the user may ;; ;; select one or more items. Includes an edit box filter ;; ;; to enable the user to filter the displayed list of items. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2013 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; msg - List box dialog title ;; ;; lst - List of strings to display in the list box ;; ;; mtp - Boolean flag to determine whether the user may ;; ;; select multiple items (T=Allow Multiple) ;; ;;------------------------------------------------------------;; ;; Returns: List of selected items, else nil. ;; ;;------------------------------------------------------------;; (defun LM:FiltListBox ( msg lst mtp / _addlist dch dcl des rtn tmp ) (defun _addlist ( key lst ) (start_list key) (foreach x lst (add_list x)) (end_list) lst ) (if (and (setq dcl (vl-filename-mktemp nil nil ".dcl")) (setq des (open dcl "w")) (write-line (strcat "filtlistbox : dialog { label = \"" msg "\"; spacer;" ": list_box { key = \"lst\"; width = 50; fixed_width = true; height = 15; fixed_height = true; allow_accept = true; " "multiple_select = " (if mtp "true" "false") "; }" ": edit_box { key = \"flt\"; width = 50; fixed_width = true; label = \"Filter:\"; }" "spacer; ok_cancel; }" ) des ) (not (close des)) (< 0 (setq dch (load_dialog dcl))) (new_dialog "filtlistbox" dch) ) (progn (_addlist "lst" (setq tmp lst)) (set_tile "lst" (setq rtn "0")) (set_tile "flt" "*") (action_tile "lst" "(setq rtn $value)") (action_tile "flt" (vl-prin1-to-string '(progn (setq flt (strcat "*" (strcase $value) "*")) (_addlist "lst" (setq tmp (vl-remove-if-not '(lambda ( x ) (wcmatch (strcase x) flt)) lst))) (set_tile "lst" (if (< (atoi rtn) (length tmp)) rtn (setq rtn "0"))) ) ) ) (setq rtn (if (= 1 (start_dialog)) (mapcar '(lambda ( x ) (nth x tmp)) (read (strcat "(" rtn ")"))) ) ) ) ) (if (< 0 dch) (setq dch (unload_dialog dch)) ) (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl) ) rtn ) ;END LM:FiltListBox ;;------------------------------------------------------------------------------------------------------------------------------------------------------------------;; ;; END OF ;; ;; [PUBLISH-LIST-LAYOUT-PLOT] ;; ;;------------------------------------------------------------------------------------------------------------------------------------------------------------------;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; ^[PUBLISH-AUTO-PUBLISH-MATIC]^ ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;; PUBLISH-AUTO-PUBLISH-MATIC ==> CHANGES THE AUTOMATIC PUBLISH VARIABLE ;; ;; ;; ;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;; ;;;AUTOMATICPUB: (defun c:PUBLISH-AUTO-PUBLISH-MATIC (/) (if (= (getvar "AUTOMATICPUB") 1) (setvar "AUTOMATICPUB" 0) (setvar "AUTOMATICPUB" 1) ) (princ (strcat "\nAUTOMATICPUB variable is set to \"" (rtos(getvar "AUTOMATICPUB")) "\" " )) (command "QSave") (setvar "AUTOMATICPUB" 0) (princ) ) ;END DEFUN ;;------------------------------------------------------------------------------------------------------------------------------------------------------------------;; ;; END OF ;; ;; [PUBLISH-AUTO-PUBLISH-MATIC] ;; ;;------------------------------------------------------------------------------------------------------------------------------------------------------------------;; Edited May 25, 2020 by Sambuddy Quote
rlx Posted May 25, 2020 Posted May 25, 2020 Hi Sambuddy, sent you a routine by private mail. Maybe it works , maybe its usefull , maybe not... as we say here : garantie tot aan de deur. I wrote this app for three people , me , myself and I so if its not working / usefull... bite me haha Quote
BIGAL Posted May 25, 2020 Posted May 25, 2020 The combined pdf is done via Ghostscript and runs after the individual pdfs are made a list of pdfs names are made. Ghostscript reads this list running under "Shell" This is the full code for multi layouts, one question do you really need all those plot size settings ? For us a A3 can be plotted twice size A1 no probs. The old "do not scale" applies. Multi GETVALS.lsp mergepdfs.lsp plotA3Pdfrange2.lsp Quote
lido Posted May 26, 2020 Posted May 26, 2020 The solution that I use involves a SCRIPT file. The program is as simple as possible. All you have to do is to select as many drawings you want and what to plot: Model, Layouts or None. Then press <ENTER> and... is time for a coffee break. How it works: 1. Options: Plotter EN ISO 5457.pc3 (attached - requires customization), Limits, Center on paper, Millimeter, Landscape, Scale 1:1... In order to test the program, you must install the plotter above. Plotting options could be modified. See the file "MPlt.lsp". 2. Paper name will be set internally by the program if the values of LIMMAX are found in the name of the paper. In fact, this is the trick! For example, in the attached drawing "TEST.dwg" the Layout named "K 01" is set as follows: LIMMIN=0,0 and LIMMAX=420,297. So the program will choose the paper "EN ISO 5457 A3 (420.00 x 297.00 mm)". Warning: The sheet will be NOT plotted if the condition regarding limits is not fulfilled; the program does not stop if a sheet cannot be plotted. 3. Plotted files will be saved in the same folder as the selected drawings, if the folder is not read-only. 4. Every selected drawing, if not read-only, will be audited, purged and zoomed at limits, ie between LIMMIN and LIMMAX. 5. Program creates the environment system variable "DIRMSCRIPT"=last used folder name. 6. Only the file "MSCRIPT.lsp" must be loaded. The file "MPlt.lst" is used internally. 7. DOSlib Library could be necessary. Good luck! EN ISO 5457.pc3 EN ISO 5457.pmp MPlt.lsp MScript.lsp Test.dwg Quote
Sambuddy Posted May 26, 2020 Author Posted May 26, 2020 15 hours ago, BIGAL said: The combined pdf is done via Ghostscript and runs after the individual pdfs are made a list of pdfs names are made. Ghostscript reads this list running under "Shell" This is the full code for multi layouts, one question do you really need all those plot size settings ? For us a A3 can be plotted twice size A1 no probs. The old "do not scale" applies. Multi GETVALS.lsp 2.07 kB · 29 downloads mergepdfs.lsp 1.05 kB · 6 downloads plotA3Pdfrange2.lsp 1.84 kB · 4 downloads @BIGAL thanks again for sending me stuff to work on - I will give them a try but I think I did try them before and was not proficient enough to shape them to my needs. the plot size setting I am using should be different for each client and even region as some tower contractors would want to print the project in Letter size and some in 8.5 x 14 and 11x17 to take them up to the tower (contractor preference). I am also required to give them specific font size depending on the print size so I could not just give them on size to print. I was interested in shostscripts but could not get it to work (simply because I am dumb not because there is something wrong with this method). Thanks anyways for always responding on my quests! Quote
Sambuddy Posted May 26, 2020 Author Posted May 26, 2020 15 hours ago, rlx said: Hi Sambuddy, sent you a routine by private mail. Maybe it works , maybe its usefull , maybe not... as we say here : garantie tot aan de deur. I wrote this app for three people , me , myself and I so if its not working / usefull... bite me haha @rlx Thanks a lot. I did respond to you on the private forum but wanted to thank you again for sharing. Quote
Sambuddy Posted May 26, 2020 Author Posted May 26, 2020 2 hours ago, lido said: The solution that I use involves a SCRIPT file. The program is as simple as possible. All you have to do is to select as many drawings you want and what to plot: Model, Layouts or None. Then press <ENTER> and... is time for a coffee break. How it works: 1. Options: Plotter EN ISO 5457.pc3 (attached - requires customization), Limits, Center on paper, Millimeter, Landscape, Scale 1:1... In order to test the program, you must install the plotter above. Plotting options could be modified. See the file "MPlt.lsp". 2. Paper name will be set internally by the program if the values of LIMMAX are found in the name of the paper. In fact, this is the trick! For example, in the attached drawing "TEST.dwg" the Layout named "K 01" is set as follows: LIMMIN=0,0 and LIMMAX=420,297. So the program will choose the paper "EN ISO 5457 A3 (420.00 x 297.00 mm)". Warning: The sheet will be NOT plotted if the condition regarding limits is not fulfilled; the program does not stop if a sheet cannot be plotted. 3. Plotted files will be saved in the same folder as the selected drawings, if the folder is not read-only. 4. Every selected drawing, if not read-only, will be audited, purged and zoomed at limits, ie between LIMMIN and LIMMAX. 5. Program creates the environment system variable "DIRMSCRIPT"=last used folder name. 6. Only the file "MSCRIPT.lsp" must be loaded. The file "MPlt.lst" is used internally. 7. DOSlib Library could be necessary. Good luck! EN ISO 5457.pc3 1.06 kB · 1 download EN ISO 5457.pmp 4.46 kB · 1 download MPlt.lsp 3.27 kB · 0 downloads MScript.lsp 12.24 kB · 0 downloads Test.dwg 64.62 kB · 0 downloads For a beverage operator, you sure know a lot! hah! that was a joke! thanks for sharing your routines - I will see if there is any line I can steal from you to make mine do the PDF combine thing I am pursuing. Thanks @lido Quote
BIGAL Posted May 26, 2020 Posted May 26, 2020 (edited) The way around multiple clients should be that your title block should reflect their plotted sheet requirement so in the plot part I use window option for picking the title block based on a known sheet size, scale also would be set so it would be easier to have a client choice and then set the plot parameters to suit. So use the multi radio buttons or toggle to set client name and size. If the clients only have 1 or 2 sheet sizes it would be easy to do a simple choice. I would expect the number of clients is not that many. BIGAL-A3 BIGAL-A1 CADTUTOR-A3 I have a version of this code that checks the user name and selects the correct printer this was used for a multi floor office so would plot to a printer on their floor at a known size and scale set as company std. (COMMAND "-PLOT" "Y" "" "DWG To PDF" "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE" "N" "W" "-6,-6" "807,560" "1=2" "C" "y" "Acad.ctb" "Y" "n" "n" "n" pdfName "N" "y" ) so change to this after selecting client name and set variables to correct value (COMMAND "-PLOT" "Y" "" "DWG To PDF" SHEETSIZE "m" "LANDSCAPE" "N" "W" BOT TOP SCALE "C" "y" YOUR.ctb "Y" "n" "n" "n" pdfName "N" "y" ) The other way is to go to each layout and read the title block name and set the correct parameters. The surveyors had multiple title blocks so had a menu option to add correct title block. Ps title block is always at 0,0 Edited May 26, 2020 by BIGAL Quote
Sambuddy Posted May 27, 2020 Author Posted May 27, 2020 31 minutes ago, maratovich said: Sambuddy Add an example of your files. I included my routine + visual representation above. 1) select page setup 2) select layouts 3) plot only those selected (using ghostscript to combine the pdfs are my issues). Quote
maratovich Posted May 27, 2020 Posted May 27, 2020 After creating separate PDFs, you want to combine them into one file using ghostscript ...Not a good idea, ghostscript is constantly changing.I think you better use special DLLs to handle PDF format.And why aren't you using Publish? This allows you to create multi-page PDF immediately. Quote
BIGAL Posted May 27, 2020 Posted May 27, 2020 (edited) Maratovich I know you have a real good plot routine recommend it often, but for me click a menu button click ok on dcl for range and sit back a Pdf is made of all layouts. Or change range, we had 3 versions of this A3, A1, A3-mono. As the version of ghostscript was saved on a server was always found by 8 staff. The original post was for multiple client requirements so a pick client and sheet size makes sense to me. The rest happens automatically. A simple list of client name, scale, size, window cnrs etc I have used Publish v's 1-2 clicks by the time you select sheets and style etc. I had problems with Publish doing weird things like just dropping a sheet even though all layouts were selected. I created 88 pages in one go and no problems. Edited May 27, 2020 by BIGAL Quote
maratovich Posted May 28, 2020 Posted May 28, 2020 BIGAL I completely agree with you. And thank you for mentioning my programs.Each person should have a choice and he decides what is more convenient for him.I asked the author for an example file to understand how it works and what its settings are.I think that the subsequent merger is not the best option.But if the author of the topic likes this, I can advise what I use - Quick PDF LibraryThis is a handy library for PDF format. I do not know if she will work with Lisp, but I think that this is possible. Quote
rlx Posted May 28, 2020 Posted May 28, 2020 I just use the publish command. Condition is dwg's are not active / open when lisp is executed and layouts have a pagesetup. Lots of routines to do or copy page setups so do a google. Here's a basic example : ; generates muliple pdfs : (defun muppet1 ( / dwg-list dsd-fn dsd-fn tab-lst pdf-path pdf-fn) ;;; list with test drawings (work) (setq dwg-lst '("D:\\users\\rlx\\documents\\pdf-publish\\Publish-Test1.dwg" "D:\\users\\rlx\\documents\\pdf-publish\\Publish-Test2.dwg")) (setq dsd-fn "D:\\Temp\\muppet1.dsd" dsd-fp (open dsd-fn "w")) ;;; write dsd header (mapcar '(lambda (s) (write-line s dsd-fp)) '("[DWF6Version]" "Ver=1" "[DWF6MinorVersion]" "MinorVer=1")) ;;; foreach layout in each drawing... (foreach dwg dwg-lst (foreach tab (setq tab-lst (vl-remove "Model" (DbxCollection dwg "layouts"))) (write-line (strcat "[DWF6Sheet:" (vl-filename-base dwg) "_" tab "]") dsd-fp) (write-line (strcat "DWG=" dwg) dsd-fp) (write-line (strcat "Layout=" tab) dsd-fp) (write-line "Setup=" dsd-fp) (write-line (strcat "OriginalSheetPath=" dwg) dsd-fp) (write-line "Has Plot Port=0" dsd-fp) (write-line "Has3DDWF=0" dsd-fp) ) ) ;;; dsd path (setq pdf-path "D:\\Temp\\" pdf-fn (strcat pdf-path "muppet1.pdf")) (mapcar '(lambda (s) (write-line s dsd-fp)) (list "[Target]" "Type=5" (strcat "DWF=" pdf-fn) (strcat "OUT=" pdf-path) "PWD=")) (if dsd-fp (progn (close dsd-fp)(gc))) (setvar 'filedia 0) (command "-publish" dsd-fn) ) ; generates one pdf : muppet2.pdf ; Publish-Test1 - Total, toilets, meetingroom, flexoffices ; Publish-Test2 - Total, toilets, offices, archive (defun muppet2 ( / dwg-list dsd-fn dsd-fn tab-lst pdf-path pdf-fn) (vl-load-com) ;;; list with test drawings (work) (setq dwg-lst '("D:\\users\\rlx\\documents\\pdf-publish\\Publish-Test1.dwg" "D:\\users\\rlx\\documents\\pdf-publish\\Publish-Test2.dwg")) ;;; create dsd file (setq dsd-fn "d:\\Temp\\muppet2.dsd" dsd-fp (open dsd-fn "w")) ;;; write dsd header (mapcar '(lambda (s) (write-line s dsd-fp)) '("[DWF6Version]" "Ver=1" "[DWF6MinorVersion]" "MinorVer=1")) ;;; foreach layout in each drawing... (foreach dwg dwg-lst (foreach tab (setq tab-lst (vl-remove "Model" (DbxCollection dwg "layouts"))) (write-line (strcat "[DWF6Sheet:" (vl-filename-base dwg) "_" tab "]") dsd-fp) (write-line (strcat "DWG=" dwg) dsd-fp) (write-line (strcat "Layout=" tab) dsd-fp) (write-line "Setup=" dsd-fp) (write-line (strcat "OriginalSheetPath=" dwg) dsd-fp) (write-line "Has Plot Port=0" dsd-fp) (write-line "Has3DDWF=0" dsd-fp) ) ) (setq pdf-path "d:\\Temp\\" pdf-fn (strcat pdf-path "muppet2.pdf")) (mapcar '(lambda (s) (write-line s dsd-fp)) (list "[Target]" "Type=6" (strcat "DWF=" pdf-fn) (strcat "OUT=" pdf-path) "PWD=")) (if dsd-fp (progn (close dsd-fp)(gc))) (command "-publish" dsd-fn) ) (defun DbxCollection ($fn $col / _pimp v dbx-doc lst) ; some init stuf (vl-load-com) (defun _pimp (s) (strcase (vl-string-trim " ;\\" (vl-string-translate "/" "\\" s)))) ; some checks (cond ((not (eq (type $fn) 'STR)) (princ (strcat "\nInvalid filename : " (vl-princ-to-string $fn)))) ((not (findfile $fn)) (princ (strcat "\nFile not found : " $fn))) ((not (eq (type $col) 'STR)) (princ (strcat "\nInvalid tablename : " (vl-princ-to-string $col)))) (t (vlax-for doc (vla-get-Documents (vlax-get-acad-object)) (and (eq (_pimp (vla-get-fullname doc)) (_pimp $fn))(setq dbx-doc doc))) (cond ((eq (type dbx-doc) 'VLA-OBJECT)) ((not (setq dbx-doc (vlax-create-object (strcat "objectdbx.axdbdocument" (if (< (setq v (atoi (getvar 'acadver))) 16) "" (strcat "." (itoa v))))))) (princ "\nUnable to start object dbx")) ((vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list dbx-doc $fn))) (princ (strcat "\nOdbx error - unable to acces : " $fn))) ) (if (and (eq (type dbx-doc) 'VLA-OBJECT) (vlax-property-available-p dbx-doc $col)) (vlax-for item (apply (read (strcat "vla-get-" $col)) (list dbx-doc)) (setq lst (cons (vla-get-name item) lst)))) ) ) (if (and (eq (type dbx-doc) 'VLA-OBJECT) (not (vlax-object-released-p dbx-doc))) (vl-catch-all-apply 'vlax-release-object (list dbx-doc))) lst ) change paths to fit your own location. Publish-Test1.dwg Publish-Test2.dwg Quote
BIGAL Posted May 28, 2020 Posted May 28, 2020 I should clarify that our projects around 200 per year were always 1 dwg each so no need to plot multiple dwgs. One of the options I looked at was to adjust the page numbering so the single pdf made reflects the total number of sheets produced from multi dwg's. The program asks for a range so you can plot 1 layout tab if you want. Quote
rlx Posted May 28, 2020 Posted May 28, 2020 well that would be easy. Routine uses (setq tab-lst (vl-remove "Model" (DbxCollection dwg "layouts"))) to get all layouts (with DbxCollection) and this list can easy be filtered with vl-member-if or something to only get the ones you need, Just made this cause colleagues sometimes want seperate pdf's and sometimes a single. Quote
BIGAL Posted May 29, 2020 Posted May 29, 2020 That's what I was doing put min 1 max 99 even if you only had 3 layouts easy to do plot all. Interesting DbxCollection. Quote
rlx Posted May 29, 2020 Posted May 29, 2020 9 hours ago, BIGAL said: That's what I was doing put min 1 max 99 even if you only had 3 layouts easy to do plot all. Interesting DbxCollection. DbxCollection , could have also called it objectdbx-tblsearch, can open a drawing and retrieve all Layers, Blocks, Styles etc as long as there is a vla function for it , so vl-get-layouts or vla-get-styles etc. So if you want a list with all blocknames for all drawings in a folder you could vl-directory-files this folder to a list, and then (foreach dwg drawing-list (setq blocklist (DbxCollection dwg "blocks") (setq total-list (cons (cons dwg blocklist) total-list))). Glad you liked it Quote
SANDIP PAITAL Posted August 6, 2023 Posted August 6, 2023 On 5/26/2020 at 4:49 AM, rlx said: Hi Sambuddy, sent you a routine by private mail. Maybe it works , maybe its usefull , maybe not... as we say here : garantie tot aan de deur. I wrote this app for three people , me , myself and I so if its not working / usefull... bite me haha please send this programming Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.