
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have a developer background and a little knowledge of lisp, but I don't know anything of autolisp, I am trying to assisit a collegue.
We are trying to create an autolisp routine to create a PDF file for some layouts only, those we identify each one by its name.
I need help to achieve.
One of the reason to create a routine is because we will call it from other script that removes several layers and creates an etransmit file. We need to attach some of the layouts as PDF to the etransmit file.
Here is my current code:
(defun c:CREATE-PDF-LAYERS(/) (setvar "cmddia" 0) (setvar "filedia" 0)
;; Define target directory (setq dir_name "C:\\Users\\jvelasco\\Desktop\\CAD test\\PDFS\\")
;; Get the Layouts from the draw (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) )
;; Get the draw name without the extension (setq dwgname (GETVAR "dwgname")) (setq len (strlen dwgname)) (setq dwgname (substr dwgname 1 (- len 4)))
;; Create a list with all the layouts (setq plottablist (acad_strlsort plotabs))
;; Loops over layouts (setq len (length plottablist)) (setq x 0)
(repeat len (setq name (nth x plottablist)) ;; Filter layers to skip Model Layer and all named as STAMIC* (if (and (not (wcmatch name "Model")) (not (wcmatch name "STAMIC*")) )
;; Define the target PDF filename with path (setq pdffile (strcat dir_name dwgname "-" name ".pdf")) ;; (prompt (strcat "Generating PDF File for layout:" name "\n")) ;; (prompt (strcat pdffile "\n"))
;; Create PDF (command "-plot" "y" name "Dwg To PDF.pc3" "ISO full bleed A3 (297.00 x 420.00 MM)" "M" "L" "N" "E" "F" "C" "Y" "C:\\Users\\jvelasco\\Desktop\\CAD test\\\\PlotCfgs\\STBFile.stb" "Y" "Y" "Y" pdffile "Y" "Y") ) (setq x (+ x 1)) )
;; Restore configuration (setvar "cmddia" 1) (setvar "filedia" 1) (setq DWGNAME nil LEN nil NAME nil PLOTTABLIST nil pdffile nil) (princ) )
The commented lines
;; (prompt (strcat "Generating PDF File for layout:" name "\n")) ;; (prompt (strcat pdffile "\n"))
show only the layout name the PDF filename only for the desired layouts, but at the moment to create the PDF file with the -plot command I can't get the PDF files created.
The command box shows the following output:
Command: CREATE-PDF-LAYERS -plot Detailed plot configuration? [Yes/No] <No>: y Enter a layout name or [?] <MP-PR>: Model Regenerating model - caching viewports. Enter an output device name or [?] <Adobe PDF>: Dwg To PDF.pc3 Enter paper size or [?] <ANSI A (11.00 x 8.50 Inches)>: ISO full bleed A3 (297.00 x 420.00 MM) Enter paper units [Inches/Millimeters] <Millimeters>: M Enter drawing orientation [Portrait/Landscape] <Landscape>: L Plot upside down? [Yes/No] <No>: N Enter plot area [Display/Extents/Limits/View/Window] <Window>: E Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <Fit>: F Enter plot offset (x,y) or [Center] <Center>: C Plot with plot styles? [Yes/No] <Yes>: Y Enter plot style table name or [?] (enter . for none) <London.stb>: C:\Users\jvelasco\Desktop\CAD test\R38 DES MP CAMINT 01-13 - Standard\PlotCfgs\OBS_STB.stb Plot with lineweights? [Yes/No] <Yes>: Y Enter shade plot setting [As displayed/legacy Wireframe/legacy Hidden/Visual styles/Rendered] <As displayed>: Y Enter file name <C:\Users\jvelasco\Desktop\CAD test\R38 DES MP CAMINT 01-13 - Standard\R38 DES MP CAMINT 01-13-Model.pdf>: Y Save changes to page setup [Yes/No]? <N> Restoring cached viewports - Regenerating layout. Command: Y Unknown command "Y". Press F1 for help. Command: Y Unknown command "Y". Press F1 for help. Command: -plot Detailed plot configuration? [Yes/No] <No>: y Enter a layout name or [?] <MP-PR>: STAMIC MP-CM Regenerating layout. Regenerating model - caching viewports. Enter an output device name or [?] <DWG To PDF.pc3>: Dwg To PDF.pc3 Enter paper size or [?] <ISO full bleed A3 (297.00 x 420.00 MM)>: ISO full bleed A3 (297.00 x 420.00 MM) Enter paper units [Inches/Millimeters] <Millimeters>: M Enter drawing orientation [Portrait/Landscape] <Landscape>: L Plot upside down? [Yes/No] <No>: N Enter plot area [Display/Extents/Layout/View/Window] <Extents>: E Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1=1>: F Enter plot offset (x,y) or [Center] <Center>: C Plot with plot styles? [Yes/No] <Yes>: Y Enter plot style table name or [?] (enter . for none) <OBS_STB.stb>: C:\Users\jvelasco\Desktop\CAD test\R38 DES MP CAMINT 01-13 - Standard\PlotCfgs\OBS_STB.stb Plot with lineweights? [Yes/No] <Yes>: Y Scale lineweights with plot scale? [Yes/No] <No>: Y Plot paper space first? [Yes/No] <No>: Y Hide paperspace objects? [Yes/No] <No>: C:\Users\jvelasco\Desktop\CAD test\PDFS\R38 DES MP CAMINT 01-13-MP-PR.pdf Restoring cached viewports - Regenerating layout. Command: Y Unknown command "Y". Press F1 for help. Command: Y Unknown command "Y". Press F1 for help. Command: -plot Detailed plot configuration? [Yes/No] <No>: y Enter a layout name or [?] <MP-PR>: STAMIC MP-JU Regenerating layout. Regenerating model - caching viewports. Enter an output device name or [?] <DWG To PDF.pc3>: Dwg To PDF.pc3 Enter paper size or [?] <ISO full bleed A3 (297.00 x 420.00 MM)>: ISO full bleed A3 (297.00 x 420.00 MM) Enter paper units [Inches/Millimeters] <Millimeters>: M Enter drawing orientation [Portrait/Landscape] <Landscape>: L Plot upside down? [Yes/No] <No>: N Enter plot area [Display/Extents/Layout/View/Window] <Extents>: E Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1=1>: F Enter plot offset (x,y) or [Center] <Center>: C Plot with plot styles? [Yes/No] <Yes>: Y Enter plot style table name or [?] (enter . for none) <OBS_STB.stb>: C:\Users\jvelasco\Desktop\CAD test\R38 DES MP CAMINT 01-13 - Standard\PlotCfgs\OBS_STB.stb Plot with lineweights? [Yes/No] <Yes>: Y Scale lineweights with plot scale? [Yes/No] <No>: Y Plot paper space first? [Yes/No] <No>: Y Hide paperspace objects? [Yes/No] <No>: C:\Users\jvelasco\Desktop\CAD test\PDFS\R38 DES MP CAMINT 01-13-MP-PR.pdf Restoring cached viewports - Regenerating layout. Command: Y Unknown command "Y". Press F1 for help. Command: Y Unknown command "Y". Press F1 for help. Command: Command: 'VLIDE Command: Command:
I don't understand why is trying to generate those "STAMIC ..." layout as PDF since the condition might skip to create the pdf in this case, and indeed it seems the desired layouts are not taken since I can't see at the execution result the name after "Enter a layout name:" line. But they are when they might not be (STAMIC ...).
This issue is strungling my brain. Anybody could see the reason?
I will continue debuging the -plot command options, but I really appreciate if some advanced person could point me to the right way.
Thank you so much to take your time of reading this question, I'll appreciate any kind of help.
Regards.
Solved! Go to Solution.