Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Quick XREF search

24 REPLIES 24
SOLVED
Reply
Message 1 of 25
rob.aHH2T8
1926 Views, 24 Replies

Quick XREF search

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!

Tags (3)
24 REPLIES 24
Message 2 of 25
paullimapa
in reply to: rob.aHH2T8

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
Message 3 of 25
rob.aHH2T8
in reply to: paullimapa

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!

Message 4 of 25
paullimapa
in reply to: rob.aHH2T8

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
Message 5 of 25
john.uhden
in reply to: paullimapa

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

Message 6 of 25
paullimapa
in reply to: john.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


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 7 of 25
rob.aHH2T8
in reply to: paullimapa

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.

Message 8 of 25
paullimapa
in reply to: rob.aHH2T8

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
Message 9 of 25
rob.aHH2T8
in reply to: paullimapa

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.

Message 10 of 25
rob.aHH2T8
in reply to: paullimapa

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

 

Thanks so much

Message 11 of 25
john.uhden
in reply to: rob.aHH2T8

Try changing part of the code from

 

(command"_.XREF"

 

 to

 

(command"_.-XREF"

  with a hyphen before the X

John F. Uhden

Message 12 of 25
rob.aHH2T8
in reply to: john.uhden

Still smallish and not expandable.

Message 13 of 25
ВeekeeCZ
in reply to: rob.aHH2T8

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)
)
Message 14 of 25
john.uhden
in reply to: rob.aHH2T8

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

Message 15 of 25
john.uhden
in reply to: rob.aHH2T8

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

Message 16 of 25
rob.aHH2T8
in reply to: john.uhden

What do you mean by precede?

Message 17 of 25
rob.aHH2T8
in reply to: john.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.

Message 18 of 25
paullimapa
in reply to: rob.aHH2T8

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
Message 19 of 25
rob.aHH2T8
in reply to: paullimapa

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.

Message 20 of 25
rob.aHH2T8
in reply to: rob.aHH2T8

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report