PDF macro, single button

PDF macro, single button

Anonymous
Not applicable
5,097 Views
26 Replies
Message 1 of 27

PDF macro, single button

Anonymous
Not applicable

Hi all,

I'm trying to reduce PDF creation in our office to a single click. I created a CUI button with the following macro, but the first time I run it, it will save the file as 'N.pdf' in my local documents folder.

 

Anybody know how to predefine the filename and directory? I always want the PDF filename to be the same as the AutoCAD filename and we always save PDFs to the same netowrk directory.

 

^C^C-plot;Y;;AutoCAD PDF (General Documentation);ANSI B (17.00 x 11.00);I;L;N;E;F;C;Y;monochrome.ctb;Y;A;N;N;Y;

 

Thanks!

Nathan

 

AutoCAD 2016

0 Likes
Accepted solutions (1)
5,098 Views
26 Replies
Replies (26)
Message 2 of 27

john.vellek
Alumni
Alumni

Good morning @Anonymous,

 

I always change the location inside the PDF Publish Options dialog. Does this work for you? 

 

Please hit the Accept as Solution button if my post fully solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 3 of 27

sthompson1021
Advisor
Advisor

One to many N's at the end. Try

 

^C^C-plot;Y;;AutoCAD PDF (General Documentation);ANSI B (17.00 x 11.00);I;L;N;E;F;C;Y;monochrome.ctb;Y;A;;N;Y;

 

0 Likes
Message 4 of 27

Anonymous
Not applicable

John,

That would seem to be a good option! But mine unfortunately does not look quite the same. Picture attached. Any ideas on where that would've got moved to?

0 Likes
Message 5 of 27

john.vellek
Alumni
Alumni

nathan.c.keeley,

 

Try it through the Publish command instead of through the Plot dialog.

 

Please hit the Accept as Solution button if my post fully solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 6 of 27

Anonymous
Not applicable

St Hompson,

So your change did help significantly. I actually got a PDF to save! Unfortunately, it only worked once. Now that there was an existing PDF in that folder, the next time I tried it, AutoCAD added a prompt for 'do you want to overwrite?', which then screws up the command order for the macro. Any ideas on getting around that?

 

Also, it is still saving in the wrong folder location and with the wrong filename...if you also have any ideas on how to change those... Feel like I'm floundering a bit here, so I appreciate the help!

 

Thanks,

Nathan

0 Likes
Message 7 of 27

Anonymous
Not applicable

John,

I did get the same options to show up through Publish as you were showing. However, it didn't seem to affect the function of my macro at all. Were you expecting it to or suggesting that I just go through Publish instead of using the -plot command in the macro?

 

Thanks!

Nathan

0 Likes
Message 8 of 27

john.vellek
Alumni
Alumni

Hi nathan.c.keeley,

 

I am sorry to hear that it didn't help in your macro. I will continue to research how this location gets determined or if you can simply add it into your macro.

 

If your ultimate goal is to print a quantity of sheets all at once, I find that the Publish or SheetSet Manager gives great results. If you haven't already done so, you might check them out.

 

Please hit the Accept as Solution button if my post fully solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 9 of 27

john.vellek
Alumni
Alumni

@sthompson1021 wrote:

One to many N's at the end. Try

 

^C^C-plot;Y;;AutoCAD PDF (General Documentation);ANSI B (17.00 x 11.00);I;L;N;E;F;C;Y;monochrome.ctb;Y;A;;N;Y;

 

^C^C-plot;Y;;AutoCAD PDF (General Documentation);ANSI B (17.00 x 11.00);I;L;N;E;F;C;Y;monochrome.ctb;Y;A;c:\temp;N;Y;

Does this work for you?

 

Please hit the Accept as Solution button if my post fully solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
Message 10 of 27

sthompson1021
Advisor
Advisor

You are experiencing one of the limitations of macros. When they get to a dialog box, they limit your choices. The default to plot a PDF is to save it in the same loction as the drawing is in. At this point you either have to accept the default or if you change the macro to allow a user input, you have to type in the location and file name you want to save it to.

 

^C^C-plot;Y;;AutoCAD PDF (General Documentation);ANSI B (17.00 x 11.00);I;L;N;E;F;C;Y;monochrome.ctb;Y;A;\N;Y;

 

I think your best bet may be to stop the macro where the save dialog box comes up and then you can pick the location and name.

 

^C^C-plot;Y;;AutoCAD PDF (General Documentation);ANSI B (17.00 x 11.00);I;L;N;E;F;C;Y;monochrome.ctb;Y;A;

 

It may be able to be done using a DIESEL expression in the macro, but thats way above my knowledge level. You may want to post in the customization group, they could maybe help with that or else point to a LISP that would do what you want as long as your not using Autocad LT

 

 

 

 

 

 

Message 11 of 27

Anonymous
Not applicable

John,

Again, that is closer I think! And I like the thought behind it, but no it doesn't seem to want to do what it to. The first time it seemed to work somewhat, but now it just saves the file in the root C: directory instead of C:\temp. I think the '\' characters are causing an issue. My AutoCAD appears to be treating them as line breaks like the ';' character. And it also still prompts for a filename as well since one isn't defined. If you have any other thoughts, please let me know! In the meantime, I'll head over to the customization forum.

 

Thanks again!

Nathan

0 Likes
Message 12 of 27

nrz13
Advisor
Advisor

I had similar issues with a PDF LISP routine and never was able to get it how I wanted.  What it amounts to is Autodesk just needs to add file name and directory options into the PDF driver.  I for one want it to prompt me for a name each time, but to remember the last saved directory.


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 32GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 13 of 27

john.vellek
Alumni
Alumni

Hi nathan.c.keeley

 

how about we come at this from another direction? Why doesn't your "one button" start a Macro that you have recorded using the Action Recorder? If you create the macro in this fashion, you could prompt the user for the file path and location. It isn't all of what you want but it gets you closer I think.

 

Please hit the Accept as Solution button if my post fully solves your issue or answers your question.

 

 


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 14 of 27

john.vellek
Alumni
Alumni

Good morning nathan.c.keeley,,

 


I am checking back to see if my post helped you with your problem. I would like to know if the Macro solution is an option for you. Please add a post with your results so other Forum users can benefit.

Please hit the Accept as Solution button if my post fully solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 15 of 27

sthompson1021
Advisor
Advisor

Nathan, if your still looking for a solution to this I've found way to do it as long as you are saving to a different drive then the one that the drawing is in. The macro I came up with is ^C^C-plot;Y;;DWG To PDF.pc3;ANSI B (17.00 x 11.00 inches);I;L;N;E;F;C;Y;monochrome.ctb;Y;A;L:/OSP/PDFS/$M=$(getvar,DWGNAME);N;Y;  This will save to our network L: drive/OSP folder/PDF folder with the drawing name as the file name. Notice that it uses forward slashes rather then back slashes in the path. That is important as it keeps the macro from reading the slashes as a user input. As I said, it will only work as long as the drawing is not on the same drive as you want to plot the pdf to. Still working on that one but have not had any luck yet.

Message 16 of 27

Anonymous
Not applicable

Thompson,

That is the best yet! Thanks for working on this, it's (almost) perfect. Any idea on how to strip the '.dwg' out of the filename? I'm ending up with something like part1.dwg.pdf. I tried to integrate the proposed solutions at https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/getvar-quot-dwgname-quot/td-p/802847 but I can't get it to work...

 

If you have any ideas on this, I'd appreciate it.

 

Thanks!

Nathan

0 Likes
Message 17 of 27

sthompson1021
Advisor
Advisor
Accepted solution

Give a man an inch, He wants a mileSmiley Wink Try this

^C^C-plot;Y;;DWG To PDF.pc3;ANSI B (17.00 x 11.00 inches);I;L;N;E;F;C;Y;monochrome.ctb;Y;A;L:/OSP/PDFS/$M=$(substr,$(getvar,DWGNAME),1,$(-,$(strlen,$(getvar,DWGNAME)),4));N;Y;

Still will not work if it's in the same drive, maybe @john.vellek has an idea on that?

Message 18 of 27

john.vellek
Alumni
Alumni

@sthompson1021,

 

What kind of error do you see indicating that it can't be the same drive? Mine seemed to work fine. ( I of course also set filedia=0)

 

 


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 19 of 27

sthompson1021
Advisor
Advisor

If I'm am in a drawing in the L drive and try to run the macro, it stops and asks if I want to save changes to page setup and then proceed with plot. It will plot the pdf after I answer the prompts, but if I am in my C drive it doesn't stop at all. The pdf is plotted with no prompts.

 

F2.PNG

0 Likes
Message 20 of 27

john.vellek
Alumni
Alumni

I don't see many options for changing the file locations. I wonder thought, if you want to try this, is to copy the DWG to PDF.pc3 into a new one and then rename it something like MyPDF. Then, go into the new file to make changes. See if making changes to the options and then creating a new plotter configuration per this article makes any difference. Maybe it is just going in circles as I am not sure why it wouldn't like the network path. Have you tried plotting to a shorter network path (I don't have such a network to test on) or even tried a UNC path?

 

Please hit the Accept as Solution button if my post fully solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes