PDA

View Full Version : Xref location path



Wish List System
2013-01-28, 12:29 PM
Summary: Xref pathing

Description: I believe, that when you go to Xref a drawing, the path of the file you are to Xref in should be of the drawing that you currently have open at that time. Instead of pathing the last file you Xreffed prior, as it can be a completley different job/project.

Product and Feature: AutoCAD - XREF

Submitted By: James Cunningham on 01/28/2013

BlackBox
2013-01-28, 05:13 PM
Xref path information is stored to the registry, and not within the Document (read Drawing) itself. There are some workarounds, and some obstacles to consider.

One option, is to roll your own Command, by employing GETFILED to prompt the user for the DWGPREFIX directory.

Another, if you don't mind using CLASSICXREF Command, is to change the registry key's value via a Visual LISP Command Reactor:



(vl-load-com)

(defun XattachFileDialog:ReactorStart ()
(if (= 1 (getvar 'rememberfolders))
(progn
(or *XattachFileDialog_Reactor*
(setq *XattachFileDialog_Reactor*
(vlr-command-reactor
"My Xref path reactor"
'(
(:vlr-commandwillstart . XattachFileDialog:CommandWillStart)
)
)
)
)
(prompt "\nXref path reactor loaded. ")
)
(prompt "\n** \"REMEMBERFOLDERS\" must be enabled ")
)
(princ)
)

(defun XattachFileDialog:CommandWillStart (rea cmd)
(if (wcmatch (car cmd) "*CLASSICXREF")
(vl-registry-write
(strcat "HKEY_CURRENT_USER\\"
(if vlax-user-product-key ; If 2013
(vlax-user-product-key) ; Use 2013 function
(vlax-product-key) ; Use legacy function
)
"\\Profiles\\"
(vla-get-activeprofile
(vla-get-profiles
(vla-get-preferences (vlax-get-acad-object))
)
)
"\\Dialogs\\XattachFileDialog"
)
"InitialDirectory"
(getvar 'dwgprefix)
)
)
)

(defun c:XrefPathAuto ()
(if *XattachFileDialog_Reactor*
(progn
(vlr-remove *XattachFileDialog_Reactor*)
(setq *XattachFileDialog_Reactor* nil)
(princ "\n** Xref path reactor unloaded ** ")
)
(XattachFileDialog:ReactorStart)
)
(princ)
)

;; Autoload, comment out if you do not want
;; this to be loaded at drawing open.
(XattachFileDialog:ReactorStart)
(princ)


... However, while this methodology can successfully change the "..\\BrowseropenDialog\\" key's InitialDirectory value in addition to that specified in the code above, AutoCAD itself changes this back to "..\\My Documents\\" folder per default behavior for XATTACH Command (ironically):




Change the Default Drawing Folder

Each time you start AutoCAD, the My Documents folder is the default path in each standard file selection dialog box. Alternatively, you can configure AutoCAD to always default to a specified path by changing the default drawing folder using the REMEMBERFOLDERS (http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ffa23ce210c4a30acaf-4eb7.htm) system variable.