Jump to content

'Open and SaveAs' default path


Aftertouch

Recommended Posts

Hello all,

 

Is it possible to change the default path of the 'SaveAs' location by lisp?

I already found out that the variable 'REMEMBERFOLDERS' triggers something, but thats not what im looking for.

 

I want to change the default path of the 'last used folder' by lisp...

 

In the REGISTER i found this option for the XATTACH


(vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (vla-get-activeprofile (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))) "\\Dialogs\\BrowseropenDialog") "InitialDirectory" (getvar "dwgprefix"))

 

But where is the 'SaveAs' / last used path stored.....

Edited by Aftertouch
Link to comment
Share on other sites

You might be able to pick something out of THIS. This code saves me tons of time browsing the network.

 

Just looked at what I'm using now and this is it:

(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")
			("Enter name of file to overlay" "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)
  )
)

 

Edited by ronjonp
*Added current code
  • Like 1
Link to comment
Share on other sites

You can "REDEFINE" a command so you could do your own "saveas" that is a lisp pointing to the correct folder location. You use UNdefine to reset it back.

Link to comment
Share on other sites

5 hours ago, Aftertouch said:

@ronjonp

Thanks for the code, this is exactly what im looking for! (Have to run some tests tho, but look like this is it.

 

Glad to help :)

Link to comment
Share on other sites

@ronjonp

I tested the code and modded it a bit for my needs. But sure helped me alot!

One thing my colleges gave back to me:

When you 'open' or 'save-as' the default 'DESKTOP' icon was missing in the menu, so i added these lines:

 


            (vl-registry-write (strcat key "AllAnavDialogs\\") "PlacesOrder6" "Desktop")
            (vl-registry-write (strcat key "AllAnavDialogs\\") "PlacesOrder6Display" "Desktop")
            (vl-registry-write (strcat key "AllAnavDialogs\\") "PlacesOrder6Ext" "")

 

Wich are the default lines for 'PlacesOrder5'. 😉

This returned the default desktop icon again.

 

Link to comment
Share on other sites

  • 2 years later...

Thank you @ronjonp for "rjp-currentpath"

It affects XREF & XATTATACH commands, but what registry key should be modified to make this work also with -XREF command, which i'm using through a lisp.

Edited by robert06
Link to comment
Share on other sites

5 hours ago, robert06 said:

Thank you @ronjonp for "rjp-currentpath"

It affects XREF & XATTATACH commands, but what registry key should be modified to make this work also with -XREF command, which i'm using through a lisp.

I'll have to dig into it not sure as of now. Figured it out 🍻

Edited by ronjonp
*updated code above to work with -xref command
Link to comment
Share on other sites

8 hours ago, robert06 said:

Hi, thank you. But in acad 2022 this still does not work for -XREF.

Strange ... I'm on 2022 and it works fine 🤔.

Link to comment
Share on other sites

On 3/27/2019 at 11:57 AM, ronjonp said:

You might be able to pick something out of THIS. This code saves me tons of time browsing the network.

 

Just looked at what I'm using now and this is it:

I've been using your 9/16/2013 version here. Updating to your current version now.

Thanks again!

Link to comment
Share on other sites

9 hours ago, robert06 said:

It works with -Xref / attach, but not with -xref / overlay.

Yup .. just tested here. I'll see if I can find that key as well.

Edited by ronjonp
  • Like 2
Link to comment
Share on other sites

While dealing with this already, it would be great, if publishing (printing) to pdf from autocad (DWG to PDF.pc3, Autocad PDF.pc3 etc) keys would be featured as well. Thank you!

Edited by robert06
Link to comment
Share on other sites

2 hours ago, robert06 said:

While dealing with this already, it would be great, if publishing (printing) to pdf from autocad (DWG to PDF.pc3, Autocad PDF.pc3 etc) keys would be featured as well. Thank you!

If you use publish it should set the default path: ("AcPublishDlg" "Location")

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...