Author Topic: (getvar 'dwgprefix) xref path  (Read 9197 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7526
(getvar 'dwgprefix) xref path
« on: May 04, 2005, 12:35:13 PM »
I've been running this in my startup at work because I hate having to browse all over the network for these files: Currently AutoCAD uses the last opened folder and this allows for the current dwgpath to be shown. I'm sure it could use some cleaning up so knock yourself out :)

One question....how can I extract this info (in red) from the registry so I don't have to hard code it?

(setq regpath  (strcat hkey version "\\ACAD-301:409\\Profiles\\" profile "\\Dialogs\\XattachFileDialog"))

Latest code is below in this thread .. tested on AutoCAD 2014.
http://www.theswamp.org/index.php?topic=5029.msg502985#msg502985

Code: [Select]
;_____________________________________________________________________________
;;SETS XREF ATTACH DIALOGUE AND SHEET MANAGER START FOLDER TO CURRENT DRAWING PATH
;_____________________________________________________________________________

(defun writereg (/  dwgpath profile hkey version regpath)
  (if (not (wcmatch (getvar 'dwgname) "Drawing*.dwg"))
    (progn
     
      (setq dwgpath  (strcat (getvar 'dwgprefix))
              profile (strcat (getvar 'cprofile))
              hkey "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\"
              version (strcat "R" (substr (getvar 'acadver) 1 4)))

      (setq regpath  (strcat hkey version "\\ACAD-301:409\\Profiles\\" profile "\\Dialogs\\XattachFileDialog"))
      (if (vl-registry-read regpath "InitialDirectory")
      (vl-registry-write regpath "InitialDirectory" dwgpath)
       )

      (setq regpath  (strcat hkey version "\\ACAD-301:409\\Profiles\\" profile "\\Dialogs\\XrefFileDialog"))
      (if (vl-registry-read regpath "InitialDirectory")
      (vl-registry-write regpath "InitialDirectory" dwgpath)
       )

      (setq regpath  (strcat hkey version "\\ACAD-301:409\\Profiles\\" profile "\\Dialogs\\Sheet Set Wizard"))
      (if (vl-registry-read regpath "BrowseForLayoutsPath")
      (vl-registry-write regpath "BrowseForLayoutsPath" dwgpath)
       )

      (setq regpath  (strcat hkey version "\\ACAD-301:409\\Profiles\\" profile "\\Dialogs\\Sheet Set Wizard"))
      (if (vl-registry-read regpath "SheetSetCreatePath")
      (vl-registry-write regpath "SheetSetCreatePath" dwgpath)
       )

      (setq regpath  (strcat hkey version "\\ACAD-301:409\\Profiles\\" profile "\\Dialogs\\eTransAddFile"))
      (if (vl-registry-read regpath "InitialDirectory")
      (vl-registry-write regpath "InitialDirectory" dwgpath)
       )

      (setq regpath  (strcat hkey version "\\ACAD-301:409\\Profiles\\" profile "\\Dialogs\\SSMNavigator"))
      (if (vl-registry-read regpath "OpenSheetSetPath")
      (vl-registry-write regpath "OpenSheetSetPath" dwgpath)
       )

      (setq regpath  (strcat hkey version "\\ACAD-301:409\\Profiles\\" profile "\\Dialogs\\SSMNavigator"))
      (if (vl-registry-read regpath "ImportLayoutsAsSheetsPath")
      (vl-registry-write regpath "ImportLayoutsAsSheetsPath" dwgpath)
       )

    )
  )
)
(writereg)
« Last Edit: August 09, 2013, 11:45:25 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(getvar 'dwgprefix) xref path
« Reply #1 on: May 04, 2005, 12:44:45 PM »
you need to look into a different registry key ...

1 - Grab the value of the key: HKLM\Software\Autodesk\AutoCAD\CurVer
2 - Use the value from #1 to get the value of key: HKLM\Software\Autodesk\AutoCAD\%value goes here%\CurVer
3 - The return value of 2 will be: ACAD-301:409 (or whatever version you have installed)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ronjonp

  • Needs a day job
  • Posts: 7526
(getvar 'dwgprefix) xref path
« Reply #2 on: May 04, 2005, 01:12:15 PM »
Thanks Keith.....with that said:

Code: [Select]
;;;;____________________________________________________________________________________________
;;;;SETS XREF ATTACH DIALOG, ETRANSMIT, AND SHEET MANAGER START FOLDER TO CURRENT DRAWING PATH
;;;;____________________________________________________________________________________________

(defun writereg   (/ DP HKCU key regpath)
  (if (= (getvar 'dwgtitled) 1)
    (progn
      (setq DP    (getvar 'dwgprefix)
       HKCU (strcat "HKEY_CURRENT_USER\\" (vlax-product-key))
       key    (strcat HKCU
          "\\Profiles\\"
          (getvar 'cprofile)
          "\\Dialogs\\"
       )
      )
      (setq regpath (strcat HKCU "\\ETransmit\\Setups\\Standard\\"))
      (vl-registry-write regpath "DestFolder" DP)

      (setq regpath (strcat key "XattachFileDialog"))
      (vl-registry-write regpath "InitialDirectory" DP)

      (setq regpath (strcat key "XrefFileDialog"))
      (vl-registry-write regpath "InitialDirectory" DP)

      (setq regpath (strcat key "Sheet Set Wizard"))
      (vl-registry-write regpath "BrowseForLayoutsPath" DP)

      (setq regpath (strcat key "Sheet Set Wizard"))
      (vl-registry-write regpath "SheetSetCreatePath" DP)

      (setq regpath (strcat key "eTransAddFile"))
      (vl-registry-write regpath "InitialDirectory" DP)

      (setq regpath (strcat key "SSMNavigator"))
      (vl-registry-write regpath "OpenSheetSetPath" DP)

      (setq regpath (strcat key "SSMNavigator"))
      (vl-registry-write regpath "ImportLayoutsAsSheetsPath" DP)
    )
  )
)
(writereg)

(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))

(defun startCommand
       (calling-reactor startcommandInfo / thecommandstart)
  (setq thecommandstart (nth 0 startcommandInfo))
  (cond
    ((= thecommandstart "XREF") (writereg))
    ((= thecommandstart "ETRANSMIT") (writereg))
    ((= thecommandstart "NEWSHEETSET") (writereg))
  )
)
« Last Edit: February 19, 2015, 10:07:55 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

hyposmurf

  • Guest
Re: (getvar 'dwgprefix) xref path
« Reply #3 on: August 09, 2013, 09:01:15 AM »

ronjonp this routine used to be really helpful, however it no longer works,maybe due to the registry locations being different for the later releases. Have you by any chance got an updated version please?

ronjonp

  • Needs a day job
  • Posts: 7526
Re: (getvar 'dwgprefix) xref path
« Reply #4 on: August 09, 2013, 09:35:56 AM »
I really miss this too .. since upgrading to 2014 it does not work :(.
I may have some down time today to try and get it working again.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7526
Re: (getvar 'dwgprefix) xref path
« Reply #5 on: August 09, 2013, 10:59:18 AM »
Hypo,

Give the following code a try .. it appears to be working in AutoCAD 2014 :).
Code - Auto/Visual Lisp: [Select]
  1. (defun rjp-currentpath (/ dp hkcu key)
  2.   ;; RJP » 2019-03-27
  3.   ;; Sets current drawing directory for XREF, ETRANSMIT, SHEETSET and PUBLISH commands
  4.   ;; Writes to registry so use at your own risk...
  5.   (cond ((= (getvar 'dwgtitled) 1)
  6.          (setq dp   (getvar 'dwgprefix)
  7.                hkcu (strcat "HKEY_CURRENT_USER\\"
  8.                             (cond ((vlax-user-product-key))
  9.                                   ((vlax-product-key))
  10.                             )
  11.                     )
  12.                key  (strcat hkcu "\\Profiles\\" (getvar 'cprofile) "\\Dialogs\\")
  13.          )
  14.          (vl-registry-write (strcat hkcu "\\ETransmit\\Setups\\Standard\\") "Destfolder" dp)
  15.          (cond ((wcmatch (getenv "username") "*")
  16.                 (vl-registry-write (strcat key "AllAnavDialogs\\") "PlacesOrder6" dp)
  17.                 (vl-registry-write
  18.                   (strcat key "AllAnavDialogs\\")
  19.                   "PlacesOrder6Display"
  20.                   "Current Directory"
  21.                 )
  22.                 (vl-registry-write (strcat key "AllAnavDialogs\\") "PlacesOrder6Ext" "")
  23.                )
  24.          )
  25.          (vl-registry-write (strcat hkcu "\\ETransmit\\Setups\\Standard\\") "Destfolder" dp)
  26.          (foreach reg '(("acad-131" "InitialDirectory")
  27.                         ("AcPublishDlg" "Location")
  28.                         ("AcSmNav:OpenSheetSet" "InitialDirectory")
  29.                         ("BrowseFolder" "InitialDirectory")
  30.                         ("BrowseforPlotFilePlotDlg" "InitialDirectory")
  31.                         ("BrowseropenDialog" "InitialDirectory")
  32.                         ("CreateTransmittalDialog" "DefaultPath")
  33.                         ("DSDNavDlg" "InitialDirectory")
  34.                         ("DWFNavDlg" "InitialDirectory")
  35.                         ("OUTPUTFOLDERDLG" "InitialDirectory")
  36.                         ("OpenSaveAnavDialogs" "InitialDirectory")
  37.                         ("PDFopenDialog" "InitialDirectory")
  38.                         ("SSMNavigator" "OpenSheetSetPath")
  39.                         ("SSMNavigator" "ImportLayoutsAsSheetsPath")
  40.                         ("Save Drawing As" "InitialDirectory")
  41.                         ("Select File" "InitialDirectory")
  42.                         ("Select a drawing to compare" "InitialDirectory")
  43.                         ;; RJP » 2022-01-05 -XREF dialog key
  44.                         ("Select Reference File" "InitialDirectory")
  45.                         ("Enter name of file to overlay" "InitialDirectory")
  46.                         ("Sheet Set Wizard" "BrowseForLayoutsPath")
  47.                         ("Sheet Set Wizard" "SheetSetCreatePath")
  48.                         ("XattachFileDialog" "InitialDirectory")
  49.                        )
  50.            (vl-registry-write (strcat key (car reg)) (cadr reg) dp)
  51.          )
  52.         )
  53.   )
  54.   (princ)
  55. )
  56. (or *current-path-reactor*
  57.     (setq *current-path-reactor* (vlr-command-reactor nil '((:vlr-commandwillstart . startcommand))))
  58. )
  59. (defun startcommand (calling-reactor startcommandinfo)
  60.   (and (wcmatch (car startcommandinfo) "*XREF,XATTACH,ETRANSMIT,*SHEET*,PUBLISH,*SAVEAS*,OPEN")
  61.        (rjp-currentpath)
  62.   )
  63. )
*edit to latest version
« Last Edit: January 07, 2022, 01:36:55 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: (getvar 'dwgprefix) xref path
« Reply #6 on: August 12, 2013, 01:02:19 AM »
Did you guys try using the vlax-machine-product-key perhaps, or the vlax-user-product-key? They work fine in 2013, as does the vlax-product-key, but it's been noted a while back that it's deprecated.

You might find my get-acad-regroots routine helpful: https://www.theswamp.org/index.php?topic=44891.msg501096#msg501096
It "should" work for any acad since 2000, though I've not tested it on 2014 yet. I'd greatly appreciate it if you could give feedback.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

hyposmurf

  • Guest
Re: (getvar 'dwgprefix) xref path
« Reply #7 on: August 12, 2013, 04:00:51 AM »
Hypo,


Give the following code a try .. it appears to be working in AutoCAD 2014 :).

Code: [Select]
;; <08.09.2013> RJP updated code and tested on AutoCAD 2014
;; Obviously this writes to the registry so use at your own risk
;; Sets current drawing directory for XREF, ETRANSMIT, SHEETSET, SAVEAS, OPEN and PUBLISH commands
(defun writereg (/ dp hkcu id key)
  (if (= (getvar 'dwgtitled) 1)
    (progn (setq dp   (getvar 'dwgprefix)
hkcu (strcat "HKEY_CURRENT_USER\\" (vlax-product-key))
key  (strcat hkcu "\\Profiles\\" (getvar 'cprofile) "\\Dialogs\\")
id   "InitialDirectory"
   )
   (vl-registry-write (strcat hkcu "\\ETransmit\\Setups\\Standard\\") "Destfolder" dp)
   (vl-registry-write (strcat key "acad-131") id dp)
   (vl-registry-write (strcat key "BrowseropenDialog") id dp)
   (vl-registry-write (strcat key "OUTPUTFOLDERDLG") id dp)
   (vl-registry-write (strcat key "Save Drawing As") id dp)
   (vl-registry-write (strcat key "OpenSaveAnavDialogs") id dp)
   (vl-registry-write (strcat key "AcPublishDlg") "Location" dp)
   (vl-registry-write (strcat key "Sheet Set Wizard") "BrowseForLayoutsPath" dp)
   (vl-registry-write (strcat key "Sheet Set Wizard") "SheetSetCreatePath" dp)
   (vl-registry-write (strcat key "SSMNavigator") "OpenSheetSetPath" dp)
   (vl-registry-write (strcat key "SSMNavigator") "ImportLayoutsAsSheetsPath" dp)
    )
  )
  (princ)
)
(writereg)


(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")
       (writereg)
  )
)

Ronjop that routine seems to work!! Thanks you very much!  :-)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: (getvar 'dwgprefix) xref path
« Reply #8 on: August 12, 2013, 08:48:35 AM »
Hypo,


Give the following code a try .. it appears to be working in AutoCAD 2014 :).

Code: [Select]
;; <08.09.2013> RJP updated code and tested on AutoCAD 2014
;; Obviously this writes to the registry so use at your own risk
;; Sets current drawing directory for XREF, ETRANSMIT, SHEETSET, SAVEAS, OPEN and PUBLISH commands
(defun writereg   (/ dp hkcu id key)
  (if (= (getvar 'dwgtitled) 1)
    (progn (setq dp   (getvar 'dwgprefix)
       hkcu (strcat "HKEY_CURRENT_USER\\" (vlax-product-key))
       key  (strcat hkcu "\\Profiles\\" (getvar 'cprofile) "\\Dialogs\\")
       id   "InitialDirectory"
      )
      (vl-registry-write (strcat hkcu "\\ETransmit\\Setups\\Standard\\") "Destfolder" dp)
      (vl-registry-write (strcat key "acad-131") id dp)
      (vl-registry-write (strcat key "BrowseropenDialog") id dp)
      (vl-registry-write (strcat key "OUTPUTFOLDERDLG") id dp)
      (vl-registry-write (strcat key "Save Drawing As") id dp)
      (vl-registry-write (strcat key "OpenSaveAnavDialogs") id dp)
      (vl-registry-write (strcat key "AcPublishDlg") "Location" dp)
      (vl-registry-write (strcat key "Sheet Set Wizard") "BrowseForLayoutsPath" dp)
      (vl-registry-write (strcat key "Sheet Set Wizard") "SheetSetCreatePath" dp)
      (vl-registry-write (strcat key "SSMNavigator") "OpenSheetSetPath" dp)
      (vl-registry-write (strcat key "SSMNavigator") "ImportLayoutsAsSheetsPath" dp)
    )
  )
  (princ)
)
(writereg)


(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")
       (writereg)
  )
)

Ronjop that routine seems to work!! Thanks you very much!  :-)


Glad to help out .. thanks for the prompt. This one has been bugging me for a bit :)>

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

BlackBox

  • King Gator
  • Posts: 3770
Re: (getvar 'dwgprefix) xref path
« Reply #9 on: August 12, 2013, 09:57:18 AM »
Give the following code a try .. it appears to be working in AutoCAD 2014 :).

FWIW -

As I understand it, newer products (2013+) use vlax-User-Product-Key... More info at the bottom of this post.

Accessing the product key was changed in .NET API as well, as shown here.

Cheers

Cheers
"How we think determines what we do, and what we do determines what we get."

ronjonp

  • Needs a day job
  • Posts: 7526
Re: (getvar 'dwgprefix) xref path
« Reply #10 on: August 12, 2013, 10:36:12 AM »
Give the following code a try .. it appears to be working in AutoCAD 2014 :) .

FWIW -

As I understand it, newer products (2013+) use vlax-User-Product-Key... More info at the bottom of this post.

Accessing the product key was changed in .NET API as well, as shown here.

Cheers

Cheers


So does this mean that vlax-product-key is going to be retired at some point?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

BlackBox

  • King Gator
  • Posts: 3770
Re: (getvar 'dwgprefix) xref path
« Reply #11 on: August 12, 2013, 11:15:39 AM »
Give the following code a try .. it appears to be working in AutoCAD 2014 :) .

FWIW -

As I understand it, newer products (2013+) use vlax-User-Product-Key... More info at the bottom of this post.

Accessing the product key was changed in .NET API as well, as shown here.

Cheers

Cheers


So does this mean that vlax-product-key is going to be retired at some point?

From the More on vlax-User-Product-Key link at the bottom of my original post:

Quote from: Hyperpics (aka Lee Ambrosius)

New Functions:
<snip>
VLAX-MACHINE-PRODUCT-KEY - Returns the AutoCAD product key from the Machine hive in the Windows Registry.  (ie. "Software\\Autodesk\\AutoCAD\\R19.0\\ACAD-B001:409")
VLAX-USER-PRODUCT-KEY - Returns the AutoCAD product keyfrom the User hive in the Windows Registry.  (ie. "Software\\Autodesk\\AutoCAD\\R19.0\\ACAD-B001:409")



Obsolete Functions:
VLAX-PRODUCT-KEY - While still supported, it is recommended to use the new function VLAX-MACHINE-PRODUCT-KEY instead which returns the same value.

... So as I understand it, while it is still supported, calls to vlax-Product-Key will result in the HKLM hive location, in lieu of the HKCU hive location (which is what we're after)... This is the reason for the simple if statement in my offering at the original post:

Code - Auto/Visual Lisp: [Select]
  1. (if vlax-user-product-key                                               ; If 2013+
  2.   (vlax-user-product-key)                                               ; Use new function
  3.   (vlax-product-key)                                                    ; Use legacy function
  4. )
  5.  
"How we think determines what we do, and what we do determines what we get."

ronjonp

  • Needs a day job
  • Posts: 7526
Re: (getvar 'dwgprefix) xref path
« Reply #12 on: August 12, 2013, 11:28:46 AM »
Cool .. thanks.  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

BlackBox

  • King Gator
  • Posts: 3770
Re: (getvar 'dwgprefix) xref path
« Reply #13 on: August 12, 2013, 11:40:00 AM »
Cool .. thanks.  :)

You're welcome; I'm happy to help.  :-)
"How we think determines what we do, and what we do determines what we get."