View Full Version : How to Show All Xref File Paths & Names
BoKirra
2008-02-19, 01:14 AM
Hi ALL,
Can anyone explain with a lisp how to find out all xrefs' path & name in a drawing?
I know "dwgprefix" & "dwgname" which are to display a drawing's path & its name.
Are there similar SVs to show xref files path & names? Or do I need to do something else?
Any help would be appreciated.
Ke
Hi ALL,
Can anyone explain with a lisp how to find out all xrefs' path & name in a drawing?
I know "dwgprefix" & "dwgname" which are to display a drawing's path & its name.
Are there similar SVs to show xref files path & names? Or do I need to do something else?
Any help would be appreciated.
Ke
This is quick and dirty, but it might get you started:
(defun c:test ()
(vl-load-com)
(vlax-for item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(if (= (vla-get-isxref item) :vlax-true)
(princ (strcat "\nXref name: "
(vla-get-name item)
" --- Path: "
(vl-string-trim (strcat (vla-get-name item) ".dwg")(vla-get-path item))))
)
)
(princ)
)
rkmcswain
2008-02-19, 02:40 AM
If you don't mind a semi-proprietary object in the drawing, you can use RTEXT to print the names of the xrefs in the drawing as an RTEXT object.
Look in the Express Tool help for the $(xrefs) function of RTEXT
BoKirra
2008-02-19, 04:40 AM
Hi ALL,
Actually, I want a xref list to be shown in a dialog box. There is a list of samples:
P:\BJ2008-001\Drawings\Xref\X-A B01.dwg
P:\BJ2008-001\Drawings\Xref\X-A B02.dwg
P:\BJ2008-001\Drawings\Xref\X-A L01.dwg
P:\BJ2008-001\Drawings\Xref\X-A L02.dwg
P:\BJ2008-001\Drawings\Xref\X-A L03.dwg
...
I don't know how it can be done.
Ke
Hi ALL,
Actually, I want a xref list to be shown in a dialog box. There is a list of samples:
P:\BJ2008-001\Drawings\Xref\X-A B01.dwg
P:\BJ2008-001\Drawings\Xref\X-A B02.dwg
P:\BJ2008-001\Drawings\Xref\X-A L01.dwg
P:\BJ2008-001\Drawings\Xref\X-A L02.dwg
P:\BJ2008-001\Drawings\Xref\X-A L03.dwg
...
I don't know how it can be done.
Ke
What is your final goal for this routine? It would help to not waste time going in the wrong direction if we had more information.
irneb
2008-02-19, 06:50 AM
The idea then is to search through the DWG's block table using the tblnext function. Then checking the DXF code 1 using assoc. If it's set, the block is an xref and the returned value from (cdr (assoc 1 blk)) is the saved path to the xref. Here's an example of what you need:
(defun c:ListXrefs (/ blk s)
(setq s "List of XRefs\n---------------------------\n"
;Init string to show in alert
blk (tblnext "BLOCK" t) ;Get 1st block
) ;_ end of setq
;; Search through all blocks
(while blk
(if (assoc 1 blk) ;Check if XRef
(setq s (strcat s (cdr (assoc 1 blk)) "\n")) ;Append to string
) ;_ end of if
(setq blk (tblnext "BLOCK")) ;Get next block
) ;_ end of while
(alert s) ;Show string in alert dialog.
(princ)
) ;_ end of defun
However, this just lists all XRefs. If you only want the top level XRef and not its nested (attached) xrefs as well - then you'll have to look at using AxtiveX.
You could of coarse have used the Reference Manager tool installed as a separate program together with AutoCAD. If your idea is to remap xrefs to a new path, then this would probably be a better option since it can work on multiple drawings at once.
BoKirra
2008-02-19, 07:14 AM
Tim,
What is your final goal for this routine? It would help to not waste time going in the wrong direction if we had more information.
The routine that I wish to build is to show the following info in a single dialog box:
1) A list of Xrefs & their paths;
2) The set of Layer State loaded;
3) The name & path of linetype definition file loaded;
4) A list of blocks used by the drawing;
5) A list of dim style available in the drawing.
Also, it would be nice providing Load/Unload or Insert/Purge functions to all tasks above in the dialog box.
Thanks,
Ke
irneb
2008-02-19, 09:47 AM
You can get all that (except for Layer States, Linetype File, Load / Purge) in the Design Centre Palette: Tools --> Palettes --> DesignCenter, or Ctrl+2. You can load linetypes, dimstyles, etc. from other DWG's.
I don't think its possible (or at least easy) to find out where the linetype was loaded from. The problem is that the linetype definition is saved within the DWG, and no data is stored as to what file was used when loading it originally. Not even what the MEASUREMENT SysVar was set to when loading the linetype, thus whether from ACAD.LIN or ACADISO.LIN. You'll have to read the LIN file and compare the specific linetype's definition to match with what was found in the file.
If I understand this portion of your request correctly, then you've come across drawings with imperial & metric linetypes loaded (or some similar custom linetypes). So setting LTSCALE gives different results in the same drawing. The only way of getting this corrected is to reload all linetypes from one file, although this does not update the linetypes used within the XRefs. In this case (with VISRETAIN set to 1) a linetype with the XREF's name prefixed will be saved seperately into the containing drawing. E.g. Say A.DWG is xrefed into B.DWG. Both A and B have linetype HIDDEN loaded, A from ACAD.LIN and B from ACADISO.LIN. In B however the lines coming from A is shown with the imperial dash lengths so they'll appear much smaller (about 1/25th) of the lines drawn in B.
There's 2 methods of correcting this:
Manual, or script: Save a layer state in B. Set VISRETAIN to 0. Open A, reload all linetypes from same LIN file as B, purge unused linetypes, Save. Swap back to A reload B. Set VISRETAIN to 1. Apply the layer state you saved previously. Swap back to B, Undo until no further Undo's are possible, Save.
Lisp: Load all linetypes from the desired LIN file. Step through the LTYPE table (tblnext "LTYPE"). Find all with a "*|*" in the name (using wcmatch). Again step through each LTYPE finding all without "*|*". Compare names between the 2 & (entmod) the "*|*" set with their corresponding LType from the set without "*|*". Purge unused LTypes.
rkmcswain
2008-02-19, 01:57 PM
I don't think its possible (or at least easy) to find out where the linetype was loaded from.
I don't see how it would be possible either. Just like you can't determine what template file was used to start a .dwg file.
BoKirra
2008-02-20, 01:28 AM
irneb,
Thanks for all your suggestions. My main point is that I don't really like to use Design Centre as it doesn't meet what I want exactly. And you've pointed out :-) :
You can get all that (except for Layer States, Linetype File, Load / Purge) in the Design Centre Palette:
...
My aim was to build this routine to perform a drawing check in a single dialog box when someone passing drawings to me. Obviously, I can do all these by clicking buttons or clicking lots of keys to open different dialog boxes. It just wast time!
Thanks again. I realy like to chat with all people here - Discussions bring me fresh ideas.
Ke
irneb
2008-02-20, 05:28 AM
You're welcome.My aim was to build this routine to perform a drawing check in a single dialog box when someone passing drawings to me.
Have you tried CAD Standards? (Tools --> CAD Standards --> Configure or Check) This basically compares the current drawing to a template. It checks stuff like Text Styles, Line Types, Dim Styles, Layer Names & -Settings. When you run the check (or if set to automatically check) you're presented with a dialog showing the difference and allowed to either Ignore or Adjust to template standard.
emccauley
2009-09-03, 07:05 PM
As mentioned, use the RTEXT command, and the DIESEL option. At the text box, type $(XREFS), then select ok. Place the rtext in the drawing (anywhere), then hit ENTER to complete the command. Click on the RTEXT object, and then explode it. It becomes an MTEXT entity at that point. You can then copy/paste into a text editor.
Hi ALL,
Actually, I want a xref list to be shown in a dialog box. There is a list of samples:
P:\BJ2008-001\Drawings\Xref\X-A B01.dwg
P:\BJ2008-001\Drawings\Xref\X-A B02.dwg
P:\BJ2008-001\Drawings\Xref\X-A L01.dwg
P:\BJ2008-001\Drawings\Xref\X-A L02.dwg
P:\BJ2008-001\Drawings\Xref\X-A L03.dwg
...
I don't know how it can be done.
Ke
RobertB
2009-09-04, 01:37 AM
As mentioned, use the RTEXT command, and the DIESEL option. At the text box, type $(XREFS), then select ok. Place the rtext in the drawing (anywhere), then hit ENTER to complete the command. Click on the RTEXT object, and then explode it. It becomes an MTEXT entity at that point. You can then copy/paste into a text editor.
Hi ALL,
Actually, I want a xref list to be shown in a dialog box. There is a list of samples:
P:\BJ2008-001\Drawings\Xref\X-A B01.dwg
P:\BJ2008-001\Drawings\Xref\X-A B02.dwg
P:\BJ2008-001\Drawings\Xref\X-A L01.dwg
P:\BJ2008-001\Drawings\Xref\X-A L02.dwg
P:\BJ2008-001\Drawings\Xref\X-A L03.dwg
...
I don't know how it can be done.
KeThis does nothing for the question of getting a list of XRefs into a dialog box. Also, this thread is over 18 months old. :shock:
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.