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

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Newt
  • Posts: 195
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: 1172
  • 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

  • Newt
  • Posts: 195
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: 223
  • 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: 1172
  • 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

  • Newt
  • Posts: 195
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: 1317
  • 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

  • Newt
  • Posts: 195
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

  • Newt
  • Posts: 195
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: 665
  • 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: 1317
  • 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

  • Newt
  • Posts: 195
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

  • Newt
  • Posts: 195
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: 1317
  • 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

  • Newt
  • Posts: 195
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

VovKa

  • Swamp Rat
  • Posts: 1317
  • Ukraine
Re: assign the plot output PDF file name, via VLISP
« Reply #15 on: January 18, 2021, 06:44:20 AM »
in few seconds, and with only with 1 (one) command !
that's what homos have been dreaming about for two million years :)

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #16 on: January 18, 2021, 09:25:17 AM »
that's what homos have been dreaming about for two million years :)
:laugh:

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #17 on: January 27, 2021, 09:49:43 AM »
But now, the SAME CODE doesn't work !

It says :
Automation Error. Description was not provided.

???

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #18 on: January 27, 2021, 10:07:07 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun VK_PLOTTOFILE    (ConfigName     MediaName Window FileName / AcadObj     ActiveDocObj ActiveLayoutObj PlotObj)
  2.         (setq   AcadObj                  (vlax-get-acad-object)
  3.                         ActiveDocObj     (vla-get-ActiveDocument AcadObj)
  4.                         ActiveLayoutObj (vla-get-ActiveLayout ActiveDocObj)
  5.         )
  6.         (vla-RefreshPlotDeviceInfo      ActiveLayoutObj                                         )
  7.         (vla-Put-ConfigName                             ActiveLayoutObj ConfigName                      )
  8.         (setq PlotObj                                           (vla-get-Plot ActiveDocObj)             )
  9.         (vla-Put-CanonicalMediaName     ActiveLayoutObj MediaName                       )
  10.  
  11.         (vla-put-UseStandardScale               ActiveLayoutObj :vlax-true                      )
  12.         (vla-Put-StandardScale                  ActiveLayoutObj 0.01                                    )
  13.  
  14.         (vla-put-PaperUnits                             ActiveLayoutObj acMillimeters           )
  15.         (vla-Put-PlotRotation                   ActiveLayoutObj ac0degrees                      )  
  16.         (vla-put-PlotOrigin ActiveLayoutObj     (vlax-make-variant (vlax-make-safearray vlax-vbDouble '(0 . 1) ) ) )
  17.         (vla-Put-CenterPlot ActiveLayoutObj :vlax-true)
  18.  
  19.         (vla-Put-PlotType ActiveLayoutObj acWindow) ; <<<<<<<<<<<
  20.         (vla-SetWindowToPlot ActiveLayoutObj
  21.                 (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1) ) (car  Window) ) )
  22.                 (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1) ) (cadr Window) ) )
  23.         )
  24.        
  25.         (vla-PlotToFile PlotObj FileName)
  26.         (foreach        o (list PlotObj ActiveLayoutObj ActiveDocObj AcadObj) (vlax-release-object o) )
  27. )
  28.  

(VK_PLOTTOFILE
   "AutoCAD PDF (High Quality Print).pc3"
   "ISO_full_bleed_A3_(420.00_x_297.00_MM)"
   (list (:PT3D2D plot-ll-pt) (:PT3D2D plot-ur-pt))
   pdf-full-file-name
)
(vla-Put-PlotType ActiveLayoutObj acWindow)
Automation Error. Invalid input

???
« Last Edit: January 27, 2021, 10:12:37 AM by domenicomaria »

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1172
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #19 on: January 27, 2021, 10:11:22 AM »
Code: [Select]
  (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)))
  )
:yes:

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1172
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #20 on: January 27, 2021, 10:14:08 AM »
try again your previous code… (do not edit the message, post a new one)

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #21 on: January 27, 2021, 10:15:46 AM »
Marco, I don't understand whay you want mean !

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1172
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #22 on: January 27, 2021, 10:16:18 AM »
See Vovka code:
Code: [Select]
  (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)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1172
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #23 on: January 27, 2021, 10:18:26 AM »
Marco, I don't understand whay you want mean !
do not completely change a message you have already posted, make a new one otherwise we do not understand anything

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #24 on: January 27, 2021, 11:34:18 AM »
Quote
do not completely change a message you have already posted,
make a new one otherwise we do not understand anything
ok !

But however the situation is what is shown in the attached JPG . . .

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1172
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #25 on: January 27, 2021, 11:40:20 AM »
Post this with your vaules:
Code - Auto/Visual Lisp: [Select]
  1. (PlotToFile "DWG To PDF.pc3"
  2.             "ANSI_A_(11.00_x_8.50_Inches)"
  3.             (list (list 0 0) (list 100 100))
  4.             (strcat (getvar "DWGPREFIX") (getvar "DWGNAME") ".pdf")
  5. )


EDIT (John): Added code tags.

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #26 on: January 27, 2021, 12:16:19 PM »
it's always the same!

In the image, it is well shown the code.

Where is the mistake ?

I checked my inputs . . . everything is right !


domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #28 on: January 27, 2021, 12:26:09 PM »
I have FOUND the MISTAKE !

The FULL FILE NAME :

"D:\\[MIT]\\- MATERA - POLIZIA - 2018\\VIE di ESODO\\MT-QUESTURA - VIE di ESODO - PIANTA PIANO SEMINTERRATO - 01 - 180.pdf"

is TOO MUCH LONG !

Only This ! ! !

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1172
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #29 on: January 27, 2021, 12:46:14 PM »
I asked to post the full command value...
For the error function see my previous post...
[size=78%]I am with my Android phone ....[/size]

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #30 on: January 27, 2021, 01:00:08 PM »
Marco, tomorrow
I will take a look to command-s function
...
Thank you

Ciao

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #31 on: April 07, 2021, 12:40:21 PM »
Normally the VovKa code
works perfectly !
. . .
But today . . .
. . .
What happens ?

VovKa

  • Swamp Rat
  • Posts: 1317
  • Ukraine
Re: assign the plot output PDF file name, via VLISP
« Reply #32 on: April 07, 2021, 03:38:55 PM »
Normally the VovKa code
works perfectly !
. . .
But today . . .
. . .
What happens ?
you've made some changes to my code

try my original version

Lee Mac

  • Seagull
  • Posts: 12458
  • London, England
Re: assign the plot output PDF file name, via VLISP
« Reply #33 on: April 07, 2021, 03:49:52 PM »
It looks as though you're setting the Plot Type to Window before defining a window to plot...

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #34 on: April 07, 2021, 04:31:21 PM »
I have used this code many dozen times. . .

And everything worked fine. . .

Perhaps the print driver is damaged. . .

I use "AutoCAD PDF (High Quality Print).pc3"

VovKa

  • Swamp Rat
  • Posts: 1317
  • Ukraine
Re: assign the plot output PDF file name, via VLISP
« Reply #35 on: April 07, 2021, 05:57:36 PM »
I have used this code many dozen times. . .
just try my unmodified code and say if it's working or not

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #36 on: April 08, 2021, 03:39:49 AM »
I removed the gray commented code,
and added, the code in the green rectangle . . .

but what I can't understand is because the same code,
yesterday morning, like many many other times,
worked perfectly,
and since yesterday afternoon it returned an error. . .

. . . rereading the code, with the modification suggested
by Lee Mac and Marc'Antonio Alessi
it seems absolutely right to me. . .

but I don't understand why it worked before. . .

anyway thank you all for your kindness and help.

Have a nice day to all

ciao

domenicomaria

  • Newt
  • Posts: 195
Re: assign the plot output PDF file name, via VLISP
« Reply #37 on: April 08, 2021, 03:45:07 AM »
. . . and I also noticed that,
the original VovKa code is right and it works. . .

. . . evidently I have made some mess:whistling:
and I have not noticed it!
. . .
I'm sorry.

Thanks

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1172
  • Marco
Re: assign the plot output PDF file name, via VLISP
« Reply #38 on: April 08, 2021, 03:52:21 AM »
...

. . . evidently I have made some mess:whistling:
and I have not noticed it!
...
You have used a old version of the code   :yes: :blink: