export multiple layouts to one pdf

export multiple layouts to one pdf

ruben.vanveerdeghem
Contributor Contributor
3,619 Views
16 Replies
Message 1 of 17

export multiple layouts to one pdf

ruben.vanveerdeghem
Contributor
Contributor

We have drawings with multiple layouts and we want to export all these layouts to one pdf file with the accoreconsole.

I found this to use:

(setq CurrDwgName (getvar "dwgname"))
(setq Fname (substr CurrDwgName 1 (- (strlen CurrDwgName) 4)))
(setq name (strcat (getvar "DWGPREFIX") Fname ".pdf"))
;Command:
-EXPORT
;type 
PDF
;What to print
A
;Enter file name <D:\FtpRoot\WorkerShared\w11i1j11\acad_test-Model.pdf>:
!name
nil

But this doesn't work. The log file of the accoreconsole is giving this as an error:

Command: -EXPORT
Enter file format [Dwf/dwfX/Pdf] <Pdf>PDF
Enter plot area [Display/Extents/Window] <Display>: A

Invalid option keyword.

 

I don't know how to solve this and de accoreconsole keeps on failing on all my testings.

Can someone help me with this?

0 Likes
Accepted solutions (1)
3,620 Views
16 Replies
Replies (16)
Message 2 of 17

pbejse
Mentor
Mentor

@ruben.vanveerdeghem wrote:
Enter plot area [Display/Extents/Window] <Display>: A
Invalid option keyword.

 


The option for this prompt can only be either of the three available answer

Enter plot area [Display/Extents/Window] <Display>: 

The script shows "A" , you can try changing that to "E" or "D"

 

 

HTH

 

0 Likes
Message 3 of 17

ruben.vanveerdeghem
Contributor
Contributor
@pbejse
I know that are the only options, but this doesn't make one pdf, it's only asking to export one layout as pdf, all the other layouts are not exported
0 Likes
Message 4 of 17

pbejse
Mentor
Mentor

Any reason why you want this via coreconsole? I would suggest you use "publish" inside AutoCAD, 

 

Separate drawing files / multiple layouts can be merged into one pdf via publish dialog

pbejse_0-1650008651565.png

HTH

 

 

 

 

 

Message 5 of 17

ruben.vanveerdeghem
Contributor
Contributor

@pbejse 

It should be using a bat file to create the pdf and to import the pdf to windchill. But I think I found the issue.

If you first make the first layout active with:

Layout
Set
Name of the first layout

 

Then the export command is working like it should be.

I'm only having an issue with inquiring the name of the first layout. Is there a command for that?

0 Likes
Message 6 of 17

ruben.vanveerdeghem
Contributor
Contributor
Accepted solution

I was able to save this problem.

If the first layout is set, accoreconsole is able to export all layouts to pdf.

(setq CurrDwgName (getvar "dwgname"))
(setq Fname (substr CurrDwgName 1 (- (strlen CurrDwgName) 4)))
(setq name (strcat (getvar "DWGPREFIX") Fname ".pdf"))
(setq Lname (nth 0 (layoutlist)))
;Command:
LAYOUT
;Set
Set
;Select
!Lname
;Command:
-EXPORT
;type 
PDF
;What to print
A
;Enter file name <D:\FtpRoot\WorkerShared\w11i1j11\acad_test-Model.pdf>:
!name
nil

 

 

0 Likes
Message 7 of 17

john.uhden
Mentor
Mentor

@ruben.vanveerdeghem 

My apologies, but this all seems foolish to me.

I suggest that you learn how to use SheetSetManager instead.

John F. Uhden

0 Likes
Message 8 of 17

Sea-Haven
Mentor
Mentor

Ok click a menu button enter the layout plot range required hey pdfs are plotted then Ghostscript joins them back into 1 PDF been doing it for years, yes need ghostscript, no need to learn more than 1 menu button click.

SeaHaven_0-1650187234746.png

 

 

 

 

0 Likes
Message 9 of 17

DC-MWA
Collaborator
Collaborator

This is awesome. How hard is it to make it open the pdf created as final action?

0 Likes
Message 10 of 17

Sea-Haven
Mentor
Mentor

You could add a startapp as last line something like (startapp "explorer" "D:\\acadtemp\\trip-Model.pdf")

 

I have though about do a All or range inside existing code.

0 Likes
Message 11 of 17

DC-MWA
Collaborator
Collaborator

After using this for the day. It looks like the last thing that happens is the ghostscript processing, so the lisp is already done. So running action on a file that is technically created by ghostscript after the fact is problemmatic. I made it open the folder in explorer at he end, this is super cool!

0 Likes
Message 12 of 17

DC-MWA
Collaborator
Collaborator

I'm wondering about deleting the separate files used to create the combined file, but this is probably the same issue since ghostscript works after the lisp (I think).

0 Likes
Message 13 of 17

Sea-Haven
Mentor
Mentor

Yeah the ghostscript is ran as a last step as its a seperate program that has the ability to merge pdfs into 1 file. I have just had problems with publish and also with mine select from menu all done with publish have to set up and make sure everything is set correct, yes could make dsd file. So need that for each DWG also.

 

As the lisp has a list of pdfnames could do a VL delete file.

 

0 Likes
Message 14 of 17

DC-MWA
Collaborator
Collaborator

I have been unable to get vl-copy or vl-delete to work. Also, not sure how that works if I plot just one tab??

0 Likes
Message 15 of 17

Sea-Haven
Mentor
Mentor

Been away a few days, so Vl-file-delete ? If pdf count is greater than 1 then delete files after running ghostscript.

0 Likes
Message 16 of 17

DC-MWA
Collaborator
Collaborator

Hello,

So I modified the program to meet my needs. It leaves a temp folder behind, but it puts the created pdf in a quickplots folder.

I have a little .bat file that cleans our server of bak files so I added the temp folders to that and it is no big deal.

I have attached the lisp so you can see what I did. And again, thank you so much. 

0 Likes
Message 17 of 17

Sea-Haven
Mentor
Mentor

Glad to see it was usefull.

0 Likes