Publish to PDF default location

Publish to PDF default location

john.uhden
Mentor Mentor
2,122 Views
13 Replies
Message 1 of 14

Publish to PDF default location

john.uhden
Mentor
Mentor

I'm sure I could figure this out myself, but it's more fun sharing these things with you hip people...

It has been _issing me off that I have to keep navigating to the project folder on the server every time I publish a sheet set to PDF.  So the answer is to slam dunk my profile every time I open a DWG to set the default publish path in the registry.

Anyone care to take a stab at it?  You are all faster than I am, especially since I lost eight of my fingers trying to sharpen my crayons on the table saw.  :]

John F. Uhden

0 Likes
2,123 Views
13 Replies
Replies (13)
Message 2 of 14

ronjonp
Advisor
Advisor

I set that path in the publish to PDF options:

ronjonp_0-1603917496094.png

I also wrote this many moons ago which runs on a reactor to set a bunch of different paths to the current drawing location. Enjoy 🙂

 

(defun rjp-currentpath (/ dp hkcu key)
  ;; RJP » 2019-03-27
  ;; Sets current drawing directory for XREF, ETRANSMIT, SHEETSET and PUBLISH commands
  ;; Writes to registry so use at your own risk...
  (cond	((= (getvar 'dwgtitled) 1)
	 (setq dp   (getvar 'dwgprefix)
	       hkcu (strcat "HKEY_CURRENT_USER\\"
			    (cond ((vlax-user-product-key))
				  ((vlax-product-key))
			    )
		    )
	       key  (strcat hkcu "\\Profiles\\" (getvar 'cprofile) "\\Dialogs\\")
	 )
	 (vl-registry-write (strcat hkcu "\\ETransmit\\Setups\\Standard\\") "Destfolder" dp)
	 (cond ((wcmatch (getenv "username") "*")
		(vl-registry-write (strcat key "AllAnavDialogs\\") "PlacesOrder6" dp)
		(vl-registry-write
		  (strcat key "AllAnavDialogs\\")
		  "PlacesOrder6Display"
		  "Current Directory"
		)
		(vl-registry-write (strcat key "AllAnavDialogs\\") "PlacesOrder6Ext" "")
	       )
	 )
	 (vl-registry-write (strcat hkcu "\\ETransmit\\Setups\\Standard\\") "Destfolder" dp)
	 (foreach reg '(("acad-131" "InitialDirectory")
			("AcPublishDlg" "Location")
			("AcSmNav:OpenSheetSet" "InitialDirectory")
			("BrowseFolder" "InitialDirectory")
			("BrowseforPlotFilePlotDlg" "InitialDirectory")
			("BrowseropenDialog" "InitialDirectory")
			("CreateTransmittalDialog" "DefaultPath")
			("DSDNavDlg" "InitialDirectory")
			("DWFNavDlg" "InitialDirectory")
			("OUTPUTFOLDERDLG" "InitialDirectory")
			("OpenSaveAnavDialogs" "InitialDirectory")
			("PDFopenDialog" "InitialDirectory")
			("SSMNavigator" "OpenSheetSetPath")
			("SSMNavigator" "ImportLayoutsAsSheetsPath")
			("Save Drawing As" "InitialDirectory")
			("Select File" "InitialDirectory")
			("Select a drawing to compare" "InitialDirectory")
			;; ;; RJP » 2022-01-05 -XREF dialog key
			("Select Reference File" "InitialDirectory")
			("Sheet Set Wizard" "BrowseForLayoutsPath")
			("Sheet Set Wizard" "SheetSetCreatePath")
			("XattachFileDialog" "InitialDirectory")
		       )
	   (vl-registry-write (strcat key (car reg)) (cadr reg) dp)
	 )
	)
  )
  (princ)
)
(or *current-path-reactor*
    (setq *current-path-reactor* (vlr-command-reactor nil '((:vlr-commandwillstart . startcommand))))
)
(defun startcommand (calling-reactor startcommandinfo)
  (and (wcmatch (car startcommandinfo) "*XREF,XATTACH,ETRANSMIT,*SHEET*,PUBLISH,*SAVEAS*,OPEN")
       (rjp-currentpath)
  )
)

 

Message 3 of 14

john.uhden
Mentor
Mentor
@ronjonp:
I don't mean one location for all PDFs.
Each job has a project folder like
K:\20 Projects\20156 \PDF
or K:\19 Projects\19219 \PDF
So I want to set the default PDF folder based on the current DWG's path,
using acaddoc.lsp or maybe I have to use S::STARTUP, whatever.
I'm sure I can figure it out by myself, but I just thought it would be fun
for those independently wealthy contributors around here who have some
spare time on their hands.
Of course I could make it more complicated by trying to figure out what
sheetset is active (that might not be related to the current DWG).

John F. Uhden

0 Likes
Message 4 of 14

john.uhden
Mentor
Mentor

After searching the registry for my current path, I just came up with this for starters:

(defun @Anonymous_plotpath ( / path)
  (setq path (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\General"))
  (setq path (vl-registry-read path "PLOTTOFILEPATH"))
)

If this is true, then I just have to extract the path I want and do a registry-write.

It's a little complicated because the DWGs are on the G: drive and they want the PDFs on the K: drive, and you can't be absolutely certain that the project folders are named exactly the same on both drives, well, except for the project number. 

John F. Uhden

0 Likes
Message 5 of 14

dbroad
Mentor
Mentor

Without programming, couldn't you just use relative paths?

2020-10-29_9-55-19.png

Architect, Registered NC, VA, SC, & GA.
Message 6 of 14

john.uhden
Mentor
Mentor
Great idea, Doug, but the path to the PDF folders is on a different drive
from where the drawings are. I have all that worked out this morning
with vl-directory-this and that.
Now I am wondering when to invoke the path change. Do you know if
Sheetset Manager calls the PLOT or PUBLISH command such that I might pick
it up via a command reactor? But by then it may already be too late to
change the plot path. I dunno.

John F. Uhden

0 Likes
Message 7 of 14

dbroad
Mentor
Mentor

I sincerely doubt that you can interject a path change during a ssm call to plot but the editor reactor reports this activity when you attempt to publish a sheetset.

; Reaction: :VLR-sysVarWillChange; argument list: (#<VLR-Editor-Reactor> ("XLOADCTL"))
; Reaction: :VLR-sysVarChanged; argument list: (#<VLR-Editor-Reactor> ("XLOADCTL" T))
; Reaction: :VLR-sysVarWillChange; argument list: (#<VLR-Editor-Reactor> ("LAYOUTREGENCTL"))
; Reaction: :VLR-sysVarChanged; argument list: (#<VLR-Editor-Reactor> ("LAYOUTREGENCTL" T))
; Reaction: :VLR-sysVarWillChange; argument list: (#<VLR-Editor-Reactor> ("PLQUIET"))
; Reaction: :VLR-sysVarChanged; argument list: (#<VLR-Editor-Reactor> ("PLQUIET" T))

I am thankful that I don't have to worry about network drives.  Have you thought about using a temporary plot folder and then sending it to the correct network path later, after the plot file has been created and reviewed?  Most of the time, I'm plotting and replotting during the checking process anyway.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 8 of 14

john.uhden
Mentor
Mentor
@Anonymous :
I appreciate your infinite sincerity, but when I get a chance I'll try some
reactors and registry slamming and report back. The trouble is that I
can't try it at home, and at work I should be working. Oh well.

John F. Uhden

0 Likes
Message 9 of 14

Jeff.Cahill85
Participant
Participant

@ronjonpplease excuse my ignorance, but I have some questions regarding the lisp.  Do i put it in this location (C:\Program Files\Autodesk\AutoCAD 20XX\Support)?

Do I need to name it something specific?

Currently, I did put it in that location and gave it a random name.  When Batch Plotting (Publish) it did not open the folder location of the drawing.  It still opened the location that is default in the Publish Options.  Do i need to change the default location?  Your help would be greatly appreciated.

Before finding your lisp, I tried the acaddoc.lsp which works if you are printing dwg to pdf in plot, but it does nothing when you publish/batch plot.

0 Likes
Message 10 of 14

pdmasonnz
Community Visitor
Community Visitor

Hey John,

I've been working though the very thing. I think reactors are way too much over kill. I simply have a lisp that loads and runs when ever a drawing is loaded. I find the drawing path with (getvar "dwgprefix") and have a function that derives the root project path from that, then adds what ever folder(s) to set a publish output sub folder. I then use the following snippet to set the paths for the project specific sub folders in the registry.

Regards

Paul

***

(setq key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\"))(ARegPut_func (strcat key "AcPublishDlg") "Location" "Path")
(ARegPut_func (strcat key "AcPublishDlg\\MRU Local") "File0" "Path")

***

0 Likes
Message 11 of 14

pdmasonnz
Community Visitor
Community Visitor

Hey John,

I've been working though the very thing. I think reactors are way too much over kill. I simply have a lisp that loads and runs when ever a drawing is loaded. I find the drawing path with (getvar "dwgprefix") and have a function that derives the root project path from that, then adds what ever folder(s) to set a publish output sub folder. I then use the following snippet to set the paths for the project specific sub folders in the registry.

Regards

Paul

***

(setq key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\"))

 

(ARegPut_func (strcat key "AcPublishDlg") "Location" "Path")


(ARegPut_func (strcat key "AcPublishDlg\\MRU Local") "File0" "Path")

***

0 Likes
Message 12 of 14

scot-65
Advisor
Advisor

@john.uhden 

 

This discussion is for command PUBLISH.

 

I use a session gremlin to store the specific destination directory path for that file.

I checked and the gremlin is "sand-boxed".

Setting the path at startup will not work where there are multiple drawings opened in the editor. The last opened file wins.

As you may know the registry has just one key for this value. And SDI is now permanently disabled.

 

One can also store the path in a dictionary object but one additional key *might be* needed to compare the current file's name to that which is stored (or other methods of identifying the file). Rewrite as required (project started life as a template).

 

 

Reactor commandwillstart:

1. Build your default path here if does not exist and store as a session gremlin.

   (or USER_PUBLISH (setq USER_PUBLISH ... ))

2. You mentioned the destination directory may not exist. This is the place to test for and build if missing.

3. Set the path in the registry.

   ...\Profiles\<<Unnamed Profile>>\Dialogs\AcPublishDlg

(vl-registry-write ... "Location" USER_PUBLISH)

 

Reactor commandended:

1. Fetch the actual path that was used and store as the session gremlin [/dictionary object].

   (setq USER_PUBLISH (vl-registry-read ... "Location"))

 

 

We start in the root directory of the project and let the user navigate to the "\PDF Files\Review Sets" or other sub-directories to the \PDF Files\ root directory as required. Once the command completed, the next time PUBLISH is called, the Location is set.

 

Command PLOT is similar - USER_PLOT

Command WBLOCK is also in my arsenal but does not have a session gremlin (set the registry key to getvar dwgprefix).

 

Hope this helps.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 13 of 14

ronjonp
Advisor
Advisor

@pdmasonnz wrote:

Hey John,

I've been working though the very thing. I think reactors are way too much over kill. I simply have a lisp that loads and runs when ever a drawing is loaded. I find the drawing path with (getvar "dwgprefix") and have a function that derives the root project path from that, then adds what ever folder(s) to set a publish output sub folder. I then use the following snippet to set the paths for the project specific sub folders in the registry.

Regards

Paul

***

(setq key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\"))

 

(ARegPut_func (strcat key "AcPublishDlg") "Location" "Path")


(ARegPut_func (strcat key "AcPublishDlg\\MRU Local") "File0" "Path")

***


@pdmasonnz 

A reactor is needed if you have multiple drawings open. Your method will not work since last opened wins. Unless you're using single document mode. (SDI = 1)

0 Likes
Message 14 of 14

Sea-Haven
Mentor
Mentor

I dont use publish so we used a Plot lisp, in the plot lisp it would set the pdf path to \pdf below the current dwg directory, yes it made the pdf if it did not exist. A second step was it would produce individual pdf's but we used Ghostscript via lisp to join them back into one pdf also. 

 

 

 

; check that pdf directory exists
(setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
(if (= (vl-file-directory-p dwgpre) nil)
(vl-mkdir dwgpre)
)

 

 

Just made finding the pdfs much easier.

 

Make it part of start up.

0 Likes