I want to be able to use the current drawing file path to search for an XREF to bring in instead of having to manually go thru windows.
Seems to me that the info of the current drawing file path is already available. Just need to combine that with a way to go straight to that file path.
Thanks!
Solved! Go to Solution.
Solved by paullimapa. Go to Solution.
sure...let's say the XREF name is called XREFDWG:
(setq xrefdwg (strcat (getvar"dwgprefix") "XREFDWG")) ; creates a text string with current drawing path and xref dwg name
(if(findfile (strcat xrefdwg ".dwg"))(command"_.XREF""_Attach" xrefdwg)) ; if this dwg file can be found, then run the xref command to attach the dwg
Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store
I perhaps was being too specific.
I want to be able to get to the same file location, not any specific xref. Once I'm in the same file, I would be able to pull any xref from that file.
Thanks!
I'm a little confused as to what you are after. I thought I already gave you the method to doing this with (getvar "dwgprefix")
Perhaps you can clarify a bit more as to what else you are trying to do?
Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store
I think maybe he wants the file selection dialog to be defaulting to the dwgprefix path.
How about if you incorporate (getfiled)?
John F. Uhden
O, I see now..perhaps something like:
(setq xrefname (getfiled"Select Drawing To Xref"(getvar"dwgprefix")"DWG"8))
(if xrefname (command"_.XREF""_Attach"(strcat (getvar"dwgprefix") xrefname)))
Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store
We have thousands of house plans in many different file locations. When I pull up any given drawing from a file I have to go search through the directory to find that exact same file in order to pull in a different drawing file as an xref. I want to be able to type in a command and go to the exact file location that the current drawing is found. Since I already have one of the drawings from that file open, I should be able to find the file more simply.
So see if this new XrefD lisp routine will work for you:
; XrefD will open a window in current path to select dwg to be xref'd
(defun c:XrefD (/ xrefname)
(setq xrefname (getfiled"Select Drawing To Xref"(getvar"dwgprefix")"DWG"8))
(if xrefname (command"_.XREF""_Attach"(strcat (getvar"dwgprefix") xrefname)))
)
Just copy & paste the above code into a text file and save it as XrefD.lsp
Then you can use Appload command to place it into Startup Suite to load automatically when you open AutoCAD.
To initiate, type: XrefD
Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store
I put it in a separate file and then referenced it in my acad lisp box. I don't think that's it.
In AutoCAD it pulls up the 'select reference file' after I select attach dwg... this is where I want it to default to the current open drawing file path.
That xrefd did it! Is there a way to make the box any bigger?
Thanks so much
Try changing part of the code from
(command"_.XREF"
to
(command"_.-XREF"
with a hyphen before the X
John F. Uhden
This one is dirty dirty... but it works with the regular dialog.
(defun c:MyAttach ( / *error*) (defun *error* (errmsg) (initdia) (command-s "_.ATTACH") (princ)) (if (/= "" (getvar 'SAVENAME)) (command "_.-ATTACH" (getvar 'SAVENAME) "")) (princ) )
I'm afraid that's what you get using (getfiled). Maybe try the DOSLIB file selection dialog.
Hmmm. The default path for XREF must be stored in the registry from the previous run of the command. I am searching for the location right now with the idea that we can change the registry value just before you run the command. That would give you exactly what you are looking for.
John F. Uhden
Found it.
This seems to work for the XATTACH dialog, but not the XREF dialog...
(vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\XattachFileDialog" ) "InitialDirectory" (getvar "dwgprefix") )
This needs to precede the "XATTACH" command.
John F. Uhden
I'd be happy with clicking on the 'found at' in the xref dialog under the open status file, but it won't let me.
Another way to resolve this issue maybe to just use Windows Explorer.
Since you already use Windows Explorer to open the dwg file from, just select the dwg you want to xref from Windows Explorer.
But select using the right mouse instead of left mouse. Then drag & drop it into the AutoCAD graphics window.
A cursor menu will appear with options to select from.
Select "Create Xref"
Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store
Using Explorer is what I can do now. (I also use Favorites which helps a bit) The whole idea is to bypass the 'Exploring' part and go directly to what I view as the 'current file'. Seems like it should be a system variable to me.
Can't find what you're looking for? Ask the community or share your knowledge.