TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: lamarn on March 25, 2009, 06:22:08 AM

Title: Define Xreffiledialog in registry
Post by: lamarn on March 25, 2009, 06:22:08 AM
I would like my xref manager to look (display) always in my current dir where the DWG is
The value is stored in the registry. See att.

Somehow i want to change this value this to the value of "savepathfile"
The initial value also the "savepathfile" at startup
How can this be done with lisp or VBA?
Title: Re: Define Xreffiledialog in registry
Post by: T.Willey on March 25, 2009, 11:07:30 AM
Look at the ' vl-registry-... ' functions.  With that being said, it might not change until Acad is opened again.
Title: Re: Define Xreffiledialog in registry
Post by: lamarn on April 08, 2009, 03:16:21 PM
Found this in Tim Spangler's Layercreator. Should work..

Code: [Select]
(defun LC_SET_PROG (/ Temp)

;; Check for Version
(if
(and
(LC_CHECK_REG "HKEY_CURRENT_USER\\Software\\Layer Creator" "Version"); Check that the registry key exsists
(= "v1.7" (vl-registry-read "HKEY_CURRENT_USER\\Software\\Layer Creator" "Version")); Check that the version is correct
)
(setq Version (vl-registry-read "HKEY_CURRENT_USER\\Software\\Layer Creator" "Version")); Set the version variable
(setq Version (vl-registry-write "HKEY_CURRENT_USER\\Software\\Layer Creator" "Version" "v1.7")); Write Version to registry
)
;; Check for BaseDirectory
(if (LC_CHECK_REG "HKEY_CURRENT_USER\\Software\\Layer Creator" "BaseDirectory")
(setq BaseDirectory (vl-registry-read "HKEY_CURRENT_USER\\Software\\Layer Creator" "BaseDirectory")); Check that the registry key exsists
(setq BaseDirectory (vl-registry-write "HKEY_CURRENT_USER\\Software\\Layer Creator" "BaseDirectory" (LC_FIND_FILE "Locating Layer Creator Directory" "Layer Creator" "lsp"))); Write new BaseDirectory to registry
)
;; Check for the LayerCreator lisp in the search path
(if (not (findfile (strcat BaseDirectory "\\LayerCreator.lsp")))
(setq BaseDirectory (vl-registry-write "HKEY_CURRENT_USER\\Software\\Layer Creator" "BaseDirectory" (LC_FIND_FILE "Locating Layer Creator Directory" "Layer Creator" "lsp"))); Write new BaseDirectory to registry
)

;; Check for LayerFiles folder
(setq Temp (strcat BaseDirectory "\\Layer Files"))
(if (not (vl-file-directory-p Temp))
(progn
(alert "** Layer Files folder was not found.  Add the Layer Files folder to the base directory and re-run **")
(exit)
)
)
;; Create list of .lyr files from directory w/o extension
(if (not (setq LayerGroupList (LC_GET_LAYER (strcat BaseDirectory "\\Layer Files") ".lyr")))
(progn
(alert "** No layer definition files were found **")
(exit)
)
)
;; If GBL:Current does not exsist set it
;; Variable used to make inserted layer current
(if (not GBL:Current)
(setq GBL:Current "0"); Clear "Make Layer Current" toggle
)
;; If GBL:Update does not exsist set it
;; Variable used to update inserted layers
(if (not GBL:Update)
(setq GBL:Update "1")
)
;; If LayerGroupPos does not exsist set it
;; Variable used to get position of Layer group Tile
(if (not LayerGroupPos)
(setq LayerGroupPos 0); Set LayerGroupPos variable to first group in list
)
;; If LayerNamePos does not exsist set it
;; Variable used to get position of Layer name tile
(if (not LayerNamePos)
(setq LayerNamePos 0); Set LayerNamePos variable to first group in list
)
)
Title: Re: Define Xreffiledialog in registry
Post by: ronjonp on April 08, 2009, 04:12:25 PM
Try putting this in your startup:

Code: [Select]
(if (not *rjp-commandreactors*)
  (setq *rjp-commandreactors* (vlr-command-reactor nil '((:vlr-commandwillstart . strtcmd))))
)

(defun strtcmd (calling-reactor strtcmdinfo / dp hkcu key regpath)
  (if (and (= (getvar 'dwgtitled) 1) (wcmatch (car strtcmdinfo) "*XREF,XATTACH"))
    (progn (setq dp   (getvar 'dwgprefix)
                 hkcu (strcat "HKEY_CURRENT_USER\\" (vlax-product-key))
                 key  (strcat hkcu "\\Profiles\\" (getvar 'cprofile) "\\Dialogs\\")
           )
           (setq regpath (strcat key "XattachFileDialog"))
           (vl-registry-write regpath "InitialDirectory" dp)
           (setq regpath (strcat key "XrefFileDialog"))
           (vl-registry-write regpath "InitialDirectory" dp)
    )
  )
  (princ)
)
Title: Re: Define Xreffiledialog in registry
Post by: lamarn on April 10, 2009, 03:46:49 AM
Works Great ! Save a lot of Browse time.
Could this also be done with OpenSaveAnavDialog?

(this way it would not matter if you open from the browser (double-click) or with file => open within Autocad)
Thanks
Title: Re: Define Xreffiledialog in registry
Post by: ronjonp on April 10, 2009, 12:04:17 PM
Works Great ! Save a lot of Browse time.
Could this also be done with OpenSaveAnavDialog?

(this way it would not matter if you open from the browser (double-click) or with file => open within Autocad)
Thanks


Give this a whirl...it's the whole enchilada  :-D

Code: [Select]
(if (not *rjp-commandreactors*)
  (setq *rjp-commandreactors* (vlr-command-reactor nil '((:vlr-commandwillstart . strtcmd))))
)

(defun strtcmd (calling-reactor strtcmdinfo / dp hkcu key regpath)
  (if (and (= (getvar 'dwgtitled) 1)
           (wcmatch (car strtcmdinfo) "*XREF,XATTACH,*SHEET*,ETRANSMIT,OPEN")
      )
    (progn (setq dp   (getvar 'dwgprefix)
                 hkcu (strcat "HKEY_CURRENT_USER\\" (vlax-product-key))
                 key  (strcat hkcu "\\Profiles\\" (getvar 'cprofile) "\\Dialogs\\")
           )
           (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)
           (setq regpath (strcat key "OpenSaveAnavDialogs"))
           (vl-registry-write regpath "InitialDirectory" dp)
    )
  )
  (princ)
)
Title: Re: Define Xreffiledialog in registry
Post by: cyberiq on April 10, 2009, 01:00:05 PM
Hi,

Copy the following code in your ACADDOC.LSP file. If you don't have one, just create it. If you have one and it contains a S::STARTUP function, paste it inside. The file should be in the SUPPORT folder of your AutoCAD install directory.

I wasn't able to find this registry key one neither of my AutoCAD installs (2006 French and English, 2008 French and English, 2009 English, 2010 English) and although I would suggest something more general, like

Code: [Select]
vl-registry-write
  (strcat
    "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\XrefFileDialog"
    "InitialDirectory"
    (getvar "dwgprefix")
  )
)

maybe it's a better idea to try this hard coded version (copied from your posted image) first:

Code: [Select]
(vl-registry-write
  (strcat
    "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\<<Unnamed Profile>>\\Dialogs\\XrefFileDialog"
    "InitialDirectory"
    (getvar "dwgprefix")
  )
)

and if it works, you can try the first one too.

HTH
Title: Re: Define Xreffiledialog in registry
Post by: lamarn on November 30, 2010, 04:06:04 AM
I would like to have my 'plot to file' directory the same as my project directory.
Anyone a clue how to do this.

Somehow the code i thought could work doesn't do the job...


      (setq dp   (getvar 'dwgprefix)
                 hkcu (strcat "HKEY_CURRENT_USER\\" (vlax-product-key))
                 key  (strcat hkcu "\\Profiles\\" (getvar 'cprofile) "\\General\\")
           )
           (setq regpath (strcat key "PlotToFilePath"))      
           (vl-registry-write regpath "InitialDirectory" dp)


Title: Re: Define Xreffiledialog in registry
Post by: ronjonp on November 30, 2010, 11:34:49 AM
Try something like this:

Code: [Select]
(vla-put-defaultplottofilepath
  (vla-get-output (vla-get-preferences (vlax-get-acad-object)))
  (getvar 'dwgprefix)
)
Title: Re: Define Xreffiledialog in registry
Post by: lamarn on December 03, 2010, 02:17:53 AM
It doesn't seem to work.
This location is not affected.. see att
Title: Re: Define Xreffiledialog in registry
Post by: Lee Mac on December 03, 2010, 07:20:03 AM
Sometimes ACAD needs to be restarted to apply registry changes.
Title: Re: Define Xreffiledialog in registry
Post by: lamarn on December 03, 2010, 07:37:02 AM
(vla-put-defaultplottofilepath
  (vla-get-output (vla-get-preferences (vlax-get-acad-object)))
  (getvar 'dwgprefix)
)

is this stored in registry?
Title: Re: Define Xreffiledialog in registry
Post by: Lee Mac on December 03, 2010, 07:42:23 AM
Yes:

Code: [Select]
(getenv "PlotToFilePath")
or

Code: [Select]
(vl-registry-read (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\Initial Setup Profile\\General") "PlotToFilePath")