Publish multiple DWG files to PDF using a batch files or Vba

Anonymous

Publish multiple DWG files to PDF using a batch files or Vba

Anonymous
Not applicable

I need a script that will convert DWG. files to PDF using a batch files. But i need to convert multiple DGW to ONE SINGLE PDF file using a batch files , i got a code that does convert a DWG to PDF but it works only with a scriptpro not with the batch file i main and only works with non read files, i need the script to work with read only files

something like in this linkhttps://forums.autodesk.com/t5/visual-basic-customization/export-dwg-to-pdf-via-vba-without-sendcomm... but im new to all this please help and dumb it downt hanks for the help

0 Likes
Reply
6,176 Views
13 Replies
Replies (13)

TRLitsey
Advisor
Advisor

Hi there,

 

When I do what you are asking I will first make the PDFs with the ACE tool.  Then I combine those with a Freebee software you can download called PDF Redirect Freeware.

 

Good luck

 

Create PDF batch routine ....

 

Screenshot - 8_2_2017 , 7_35_15 AM.png

 

 

Merge as many PDFs as you want into a single PDF file ....

 

 

Screenshot - 8_2_2017 , 7_33_55 AM.png

Please mark as a solution if this works for you, kudos are always welcome

TRLitsey
Advisor
Advisor

And just in case you have not seen this before, when you get to the Batch Plot Options and Order window you will want to use the Browse button to select the DWG to PDF.pc3 AND designate the path for where the PDFs will be created.  The most common mistake is to not select/designate the path for the files to be created.  If you do not set a path it will look like the routine is working but the files being created will just disappear into vaporware.

 

Good luck

 

 

Screenshot - 8_2_2017 , 7_44_47 AM.png

Please mark as a solution if this works for you, kudos are always welcome

rhesusminus
Mentor
Mentor

Hi there.

 

If I were you I'd read up on the DSD-format used by the PUBLISH command to create multi sheet PDFs. It's a text-file that can be created programmatically (via VBA) and then you can use sendcommand in VBA to run the -PUBLISH command with the DSD-file as a parameter.

If you're using AutoCAD Electrical to create the PDF you can also get "intelligent"/Surfable PDF's.

 

And @TRLitsey ... Why would you do it in such a difficult way? Why don't you create a multi sheet PDF directly from AcadE?

 

 


Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. ๐Ÿ˜‰
0 Likes

TRLitsey
Advisor
Advisor

Well, I guess the best answer would be that I am an old dog and that is just the way I have done it since before the lovely batch plot tool we have today.

 

The other answer would be that the Document Control group requested that the single PDF contain more than just drawing files and I just didn't think to try and combine them within ACE.  Do you have a slick workflow to do that?

 

Thank you

 

 

 

Please mark as a solution if this works for you, kudos are always welcome
0 Likes

Anonymous
Not applicable

im new to most of this, but what im doing is creating a script that will publish projects to pdf, also i made a batch file to run said script.

im issue is dont know how to wirte the script.

i have an idea which is the following:

(setq pathtxt "C:\\Users\\user\\Documents\\Scripts\\p13043 ER300.dsd")


(setq OldFda (getvar "FILEDIA")) ;reads current system variable FILEDIA value
(setvar "FILEDIA" 0) ;sets FILEDIA to 0 so no dialog boxes popup

(command "-Publish" pathtxt ) ;start publish command with .DSD file
(setvar "FILEDIA" OldFda) ;sets system variable FILEDIA back to original value

0 Likes

TRLitsey
Advisor
Advisor

So the issue here is for you to learn how to write script?  And creating PDFs just happen to be what your target is for this script creation?

 

 

 

Please mark as a solution if this works for you, kudos are always welcome
0 Likes

Anonymous
Not applicable

my goal is to create a script that will publish projects (to PDF)using a batch files, i have multiple projects that need to be publish and i cant do it manually .

0 Likes

rhesusminus
Mentor
Mentor
Well, you seem to know how to automatically publish a DSD-file.
So, reverse engineer the DSD-format (It's really quite easy), and create all the DSD-files you need.
Them create a script (SCR file) that contains all the code needed. Start the Script within AutoCAD with the SCRIPT command.

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. ๐Ÿ˜‰

Anonymous
Not applicable

it looks like i know but i dont know, story of my life.

i got the script to publish projects for me but it required the .dsd file of said project how can i get the .dsd file without publish?

is there anyway?

0 Likes

rhesusminus
Mentor
Mentor
Yes, you can create it with code. Try to open the DSD-file with notepad, and you will see.
If you can't code this yourself, pay someone who can.

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. ๐Ÿ˜‰
0 Likes

revans1234
Enthusiast
Enthusiast

Hi rhesusminus,

 

What you are saying makes perfect sense as always, but I am missing something with this part.

 

"you can use sendcommand in VBA to run the -PUBLISH command with the DSD-file as a parameter."

 

My code looks like this-

 

 Dim ss As String
ss = "_-PUBLISH D:\W30-E-01 AUTO DSD.dsd"
Call MES_MOD.CMD(ss) 'THIS ROUTINE IS SENDCOMMAND WITH THE STRING PARAMETER FOLLOWED BY vbCrLf

 

The MES_MOD.CMD function is this and has worked fine for years-

 

ss = Trim(ss) & "|"
ss = Replace(ss, "|", vbCr)
Debug.Print ss
ThisDrawing.SendCommand (ss)

 

When I run this it opens the dsd selection box for PUBLISH but does not enter text in box. If select file from there it does run ok.

 

If I look in the official docs for SendCommand the example is this.

ThisDrawing.SendCommand "_Circle" & vbCr & "2,2,0" & vbCr & "4" & vbCr

 

If I try publish then vbcr then the filename and vbcr, get the same result and then an unknown command for the filename.

 

Do you see what I am doing wrong? Do I have to enclose the filename in something before it will get entered?

 

Thanks and regards,

 

Roger.

 

PS Spot on with the DSD files. They reverse engineer fine.

 

0 Likes

rhesusminus
Mentor
Mentor
The problem is the dialogs. You can't "script" dialogs. So, add "FILEDIA 0" and "FILEDIA 1" at the beginning and the end of your command string 'ss'.

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. ๐Ÿ˜‰

revans1234
Enthusiast
Enthusiast

The part with FILEDIA solves it. I would never have thought of that. Thank you very much.

0 Likes