Author Topic: assign the plot output PDF file name, via VLISP  (Read 1949 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Bull Frog
  • Posts: 235
assign the plot output PDF file name, via VLISP
« on: January 17, 2021, 11:18:54 AM »
I have a great DWG
and I need to print 22 parts of this DWG
from Model Space.

I made a block that is a rectangle .

Each insert of this block defines the corners of the window
of one of the 22 plots.

This block contains an attribute that contains the
OUTPUT PDF file name.


Obviously every insert contains a different OUTPUT PDF file name.

I want plot 22 parts (the size is A2) of the DWG
only with 1 (ONE) command.

Every thing is easy.

But I am not able to assign
the plot output PDF file name, via VLISP.

I have seen (setenv "plottofilepath" my-plot-path)

That is useful.

But I need to assign
the plot output PDF file name, via VLISP.

Is it possible ?

I don't want see, after the PLOT command,
the PDF CREATOR window.


I want plot with 1 (one) command only.

Any suggestion ?
« Last Edit: January 17, 2021, 11:23:38 AM by domenicomaria »

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1189
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #1 on: January 17, 2021, 12:37:24 PM »
it's a PDF Creator setting, why don't you use: (if BricsCAD "Print As PDF.pc3" "DWG To PDF.pc3") ?

domenicomaria

  • Bull Frog
  • Posts: 235
Re: assign the plot output PDF file name, via VLISP
« Reply #2 on: January 17, 2021, 12:46:46 PM »
The Lisp has to set 22 times,
22 different output file names.

Is it possible ?

tombu

  • Bull Frog
  • Posts: 226
  • ByLayer=>Not0
Re: assign the plot output PDF file name, via VLISP
« Reply #3 on: January 17, 2021, 01:01:57 PM »
Of course using layouts for plotting (only way recommended in AutoCAD Help for 27 years now) with Page Setups assigned to Layout allows you to simply use Publish command to do this.

The amount of time wasted on figuring out how to do something the wrong way astounds me.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1189
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #4 on: January 17, 2021, 01:04:26 PM »
The Lisp has to set 22 times,
22 different output file names.

Is it possible ?
:yes:  try with DWG To PDF

domenicomaria

  • Bull Frog
  • Posts: 235
Re: assign the plot output PDF file name, via VLISP
« Reply #5 on: January 17, 2021, 01:30:10 PM »
The amount of time wasted on figuring out how to do something the wrong way astounds me.


I agree with you.
What you say is always the best way.

But anyway I have to do what I asked if it is possible!

It is a long thing to explain. . . I work with other people. . .

VovKa

  • Swamp Rat
  • Posts: 1321
  • Ukraine
Re: assign the plot output PDF file name, via VLISP
« Reply #6 on: January 17, 2021, 03:18:35 PM »
But I need to assign
the plot output PDF file name, via VLISP.

Is it possible ?
vla-PlotToFile

domenicomaria

  • Bull Frog
  • Posts: 235
Re: assign the plot output PDF file name, via VLISP
« Reply #7 on: January 17, 2021, 03:27:13 PM »
vla-PlotToFile

. . .
VovKa you are very smart. . .
. . .
show me an example, please
. . .
I tried before but something went wrong!

domenicomaria

  • Bull Frog
  • Posts: 235
Re: assign the plot output PDF file name, via VLISP
« Reply #8 on: January 17, 2021, 03:58:34 PM »
Vovka
it PLOTS TO FILE
but generates a PLT file
and NOT a PDF !

(vl-cmdf
"-PLOT"

; Detailed plot configuration? [Yes/No]
"Yes"
; Enter a layout name or [?] <Model>:
"MODEL"
; Enter an output device name or [?] <PDFCreator>:
"PDFCreator"
; Enter paper size or [?] <A4>:
"A2"
; Enter paper units [Inches/Millimeters] <Inches>:
"Millimeters"
; Enter drawing orientation [Portrait/Landscape] <Portrait>:
"Portrait"
; Plot upside down? [Yes/No] <No>:
"No"
; Enter plot area [Display/Extents/Limits/View/Window] <Window>:
"Window"
; Enter lower left corner of window
plot-ll-pt
; Enter upper right corner of window
plot-ur-pt
; Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <Fit>:
"Fit"
; Enter plot offset (x,y) or Center :
"center"
; Plot with plot styles? [Yes/No] <No>:
"No"
; Enter plot style table name or [?] (enter . for none) <>:
"."
; Plot with lineweights? [Yes/No] <Yes>:
"No"
; Enter shade plot setting [As displayed/Wireframe/Hidden/Rendered] <As displayed>:
"As displayed"
; Write the plot to a file [Yes/No] <N>:
"Yes"
pdf-full-file-name

; Save changes to page setup [Yes/No]? <N>
"Yes"
; Proceed with plot [Yes/No] <Y>:
"Yes"
)
« Last Edit: January 17, 2021, 04:05:50 PM by domenicomaria »

BIGAL

  • Swamp Rat
  • Posts: 674
  • 30 + years of using Autocad
Re: assign the plot output PDF file name, via VLISP
« Reply #9 on: January 17, 2021, 05:38:28 PM »
Here is a start for plot all in Model space, you will need to edit stuff like block name (2 . "your blockname) and some of the other values like A2. Maratovich has a extensive plot routine that does lots of stuff way better than just this.

Somewhere have the check scale of title block so reset the scale and plot limits. I Use layouts all the time.

Code: [Select]
; plot all title blocks in model space
; By Alan H 2005

 (PROMPT ".....PRINTING DRAWING TO plotter....")
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
 : Da1drsht is titel block name
(setq ss2 (ssget "x" '((0 . "INSERT")(2 . "Da1drsht")(410 . "Model"))))
(setq n (sslength ss2))

(setq index 0)
(repeat n
    (setq en (ssname ss2 index))
    (setq el (entget en))
    (setq inspt (assoc 10 el)) ; insertion pt this is lower left for this code

   (setq xmin (- (cadr inspt) 6.0))
   (setq ymin (- (caddr inspt) 6.0))
   (setq xymin (strcat (rtos xmin 2 1) "," (rtos ymin 2 1)))

   (setq xmax (+ xmin 813.0)) ; hard coded for 813 wide 6mm offset
   (setq ymax (+ ymin 566.0)) ;hard code for 566 high
   (setq xymax (strcat (rtos xmax 2 1) "," (rtos ymax 2 1)))


  (COMMAND "-PLOT"  "Y"     "" "Design-5100"
       "A3" "M"     "LANDSCAPE"   "N"
       "W"   xymin   xymax "1=2"  "C"
       "y"   "Designlaser.ctb"      "Y"   "" "n"   "n"
       "y"
    )
   
  (setq index (+ index 1))

)

(setvar "osmode" oldsnap)
(princ)
A man who never made a mistake never made anything

VovKa

  • Swamp Rat
  • Posts: 1321
  • Ukraine
Re: assign the plot output PDF file name, via VLISP
« Reply #10 on: January 17, 2021, 07:08:06 PM »
show me an example, please
Code: [Select]
(vl-load-com)
(defun PlotToFile (ConfigName MediaName Window FileName / AcadObj ActiveDocObj ActiveLayoutObj PlotObj)
  (setq AcadObj (vlax-get-acad-object)
ActiveDocObj (vla-get-ActiveDocument AcadObj)
ActiveLayoutObj (vla-get-ActiveLayout ActiveDocObj)
  )
  (vla-RefreshPlotDeviceInfo ActiveLayoutObj)
  (vla-Put-ConfigName ActiveLayoutObj ConfigName)
  (setq PlotObj (vla-get-Plot ActiveDocObj))
  (vla-Put-CanonicalMediaName ActiveLayoutObj MediaName)
  (vla-Put-StandardScale ActiveLayoutObj acScaleToFit)
  (vla-Put-PlotRotation ActiveLayoutObj ac0degrees)
  (vla-put-PlotOrigin
    ActiveLayoutObj
    (vlax-make-variant (vlax-make-safearray vlax-vbDouble '(0 . 1)))
  )
  (vla-Put-CenterPlot ActiveLayoutObj :vlax-false)
  (vla-SetWindowToPlot
    ActiveLayoutObj
    (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1)) (car Window)))
    (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1)) (cadr Window)))
  )
  (vla-Put-PlotType ActiveLayoutObj acWindow)
  (vla-PlotToFile PlotObj FileName)
  (foreach o (list PlotObj ActiveLayoutObj ActiveDocObj AcadObj) (vlax-release-object o))
)
(PlotToFile "DWG To PDF.pc3"
    "ANSI_A_(11.00_x_8.50_Inches)"
    (list (list 0 0) (list 100 100))
    (strcat (getvar "DWGPREFIX") (getvar "DWGNAME") ".pdf")
)

domenicomaria

  • Bull Frog
  • Posts: 235
Re: assign the plot output PDF file name, via VLISP
« Reply #11 on: January 17, 2021, 11:15:02 PM »
BIGAL
i need to assign the FULL PDF file name
for each insert that defines the corners of the window to plot

While the file name (without the path) is contained in the attibute of the insert.

I am able to do every thing.

But I am not able to assign at run time the name of the file.

Where and when have I to put it ?

And this is not present in your code !

« Last Edit: January 17, 2021, 11:46:24 PM by domenicomaria »

domenicomaria

  • Bull Frog
  • Posts: 235
Re: assign the plot output PDF file name, via VLISP
« Reply #12 on: January 17, 2021, 11:43:15 PM »
VovKa
thank you very much !

(PlotToFile
   "PDFcreator"
   "A2"   ;   
   (list (setq llpt (getpoint "\nll corner"))  (setq urpt (getcorner llpt "\nur corner")))
   (strcat (getvar "DWGPREFIX") "FULL-FILE-NAME-TEST" ".pdf")
)

but I get : error: Automation Error. Invalid input
(vla-put-CanonicalMediaName #<VLA-OBJECT IAcadLayout 130f1be4> "A2")

. . .
but for PDFcreator this is the list of Canonical Media Names :

("Dimensione personalizzata pagina PostScript" "TV HDTV 1920x1080" "TV HDTV 1280x720" "TV PAL 720x576" "TV PAL Square Pix 768x576" "TV NTSC D1 Square Pix 720x540" "TV NTSC D1 720x486" "TV NTSC DV 720x480" "Screen 1280x1024 (SXGA)" "Screen 1024x768 (XGA)" "Screen 800x600 (SVGA)" "Screen 640x480 (VGA)" "92x92" "Oversize A0" "Oversize A1" "Oversize A2" "PA4" "HalfLetter" "FLSE" "FLSA" "C6" "C5" "C4" "C3" "C2" "C1" "C0" "JIS B6" "JIS B5" "JIS B4" "JIS B3" "JIS B2" "JIS B1" "JIS B0" "ISO B6" "ISO B5" "ISO B4" "ISO B3" "ISO B2" "ISO B1" "ISO B0" "A10" "A9" "A8" "A7" "A4 Small" "LetterSmall" "A0" "A1" "ARCH E3" "ARCH E2" "ARCH E1" "ARCH E" "ARCH D" "ARCH C" "ARCH B" "ARCH A" "ANSI F" "ANSI E" "ANSI D" "ANSI C" "Legal" "Letter" "A6" "A2" "A5" "A4" "A3" "Ledger" "Tabloid")

And "A2" is present !






VovKa

  • Swamp Rat
  • Posts: 1321
  • Ukraine
Re: assign the plot output PDF file name, via VLISP
« Reply #13 on: January 18, 2021, 03:45:08 AM »
but for PDFcreator
i do not use PDFCreator
so can not comment on that

domenicomaria

  • Bull Frog
  • Posts: 235
Re: assign the plot output PDF file name, via VLISP
« Reply #14 on: January 18, 2021, 05:04:15 AM »
VovKa, your code WORKS !

   (setq llpt (getpoint "\nll corner"))
   (setq urpt (getcorner llpt "\nur corner"))
   (PlotToFile
      "DWG To PDF.pc3"
      "ISO_A2_(594.00_x_420.00_MM)"
      (list (:PT3D2D llpt)  (:PT3D2D urpt) )
      (strcat (getvar "DWGPREFIX") "FULL-FILE-NAME-TEST" ".pdf")
   )

Thank you very much.

Soon I will be able to print 22 parts ot the same drawing
in few seconds, and with only with 1 (one) command !

I believe that
THIS is the BEST WAY !

thanks a lot, again !

Ciao