Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Quick XREF search

rob.aHH2T8
Enthusiast

Quick XREF search

rob.aHH2T8
Enthusiast
Enthusiast

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!

0 Likes
Reply
Accepted solutions (1)
2,055 Views
24 Replies
Replies (24)

paullimapa
Mentor
Mentor

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


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

rob.aHH2T8
Enthusiast
Enthusiast

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!

0 Likes

paullimapa
Mentor
Mentor

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


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

john.uhden
Mentor
Mentor

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

0 Likes

paullimapa
Mentor
Mentor

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


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

rob.aHH2T8
Enthusiast
Enthusiast

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.

0 Likes

paullimapa
Mentor
Mentor
Accepted solution

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


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

rob.aHH2T8
Enthusiast
Enthusiast

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.

0 Likes

rob.aHH2T8
Enthusiast
Enthusiast

That xrefd did it!  Is there a way to make the box any bigger?

 

Thanks so much

0 Likes

john.uhden
Mentor
Mentor

Try changing part of the code from

 

(command"_.XREF"

 

 to

 

(command"_.-XREF"

  with a hyphen before the X

John F. Uhden

0 Likes

rob.aHH2T8
Enthusiast
Enthusiast

Still smallish and not expandable.

0 Likes

ВeekeeCZ
Consultant
Consultant

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)
)
0 Likes

john.uhden
Mentor
Mentor

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

0 Likes

john.uhden
Mentor
Mentor

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

0 Likes

rob.aHH2T8
Enthusiast
Enthusiast

What do you mean by precede?

0 Likes

rob.aHH2T8
Enthusiast
Enthusiast

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.

0 Likes

paullimapa
Mentor
Mentor

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


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

rob.aHH2T8
Enthusiast
Enthusiast

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.

0 Likes

rob.aHH2T8
Enthusiast
Enthusiast

* 'current folder' would be the more accurate term.

0 Likes