PDA

View Full Version : Getting the File Path for XRefs



Marshal_Rosenberg60828
2004-06-25, 02:53 PM
Hi all,

I need to be able to programatically get a list of XRef files with full path info.
The 2004 help file mentions a Path property for a AcadExternalReference object. While I am able to get the File Name by searching for Blocks with IsXRef = .T., I'm not clear how to get to the Path property.

Marshal_Rosenberg60828
2004-06-25, 02:59 PM
Hi all,

I figured out a way to accomplish this by using the Block.Document.Fullname property for Blocks with IsXRef = .T.

Marshal_Rosenberg60828
2004-06-25, 03:19 PM
I guess I spoke to soon...

Now I'm totally confused...the Document Object for a Block which has XRef = .T., doesn't always have a FullName property (see the 2004 Sample drawing 8th floor plumbing.dwg).

Help!

richard.binning
2004-06-25, 03:36 PM
Try this:


Public Sub LocalDeps()
Dim myFileDeps As AcadFileDependencies
Dim myFileDep As AcadFileDependency
Set myFileDeps = ThisDrawing.FileDependencies
For Each myFileDep In myFileDeps
If myFileDep.Feature Like "Acad:XRef" Then
ThisDrawing.Utility.Prompt "XREF: " & myFileDep.FileName & " Found Path is :" & myFileDep.FullFileName & vbCrLf
End If
Next myFileDep
End Sub

Marshal_Rosenberg60828
2004-06-25, 04:02 PM
Hi Richard,

Thanks for your reply...

For some reason both my and your code fails with the 2004 sample I mentioned above.

Marshal_Rosenberg60828
2004-06-25, 04:04 PM
Also,

I've noticed that the File Dependency object does not pick up enbedded images with older AutoCad drawings...Please see my other post "Getting a List of Attached images"

richard.binning
2004-06-25, 04:13 PM
Hi Richard,

Thanks for your reply...

For some reason both my and your code fails with the 2004 sample I mentioned above.
The code worked for me, please check your code for typos. Here is the result:

XREF: 8th floor plan.dwg Found Path is :C:\v078files-resaved\ACAD\Sample\8th floor plan.dwg
XREF: 8th floor plan.dwg Found Path is :C:\My Documents\Autodesk\Red Deer\Samples\1-31 Submission\8th floor plan.dwg
XREF: 8th floor plan.dwg Found Path is :C:\Program Files\ADT2004\Sample\8th
floor plan.dwg

Note: the foundpath will display empty unless the xref is found in a path other than its full file name...

RLB

richard.binning
2004-06-25, 04:18 PM
Thats is correct, the File Dependencies objects are new to 2004, so they don't exist in a drawing until that drawing file is saved with 2004 or higher.

RLB

Marshal_Rosenberg60828
2004-06-25, 04:22 PM
Hi Richard,

I'm dealing with some files created earlier than 2004...how can I get the File Path for these?

RobertB
2004-06-25, 04:30 PM
The only way to get XRef paths in older versions is to get the ExternalReference object (the actual insertion of the XRef, not the Block object in the Blocks collection) and examine the Path property.

Marshal_Rosenberg60828
2004-06-25, 04:49 PM
Hi Robert,

That was my original way of thinking...as I stated in my initial post on this thread, I don't know how to obtain a reference to the ExternalReference Object.

RobertB
2004-06-25, 04:54 PM
Two ways:

Create a filtered selection set, iterate thru that
Iterate thru all the Layout objects, looking for ExternalReference objects

Marshal_Rosenberg60828
2004-06-25, 05:04 PM
What Object.Property Identifies an Object as an ExternalReference Object?

richard.binning
2004-06-25, 05:13 PM
What Object.Property Identifies an Object as an ExternalReference Object?
Heres a bag of fish for you....



Public Sub GetMyXrefs()
Dim objLayout As AcadLayout
Dim objBlock As AcadBlock
Dim objBlockRef As AcadBlockReference
Dim msg
For Each objLayout In ThisDrawing.Layouts
Set objBlock = objLayout.Block
For Each ent In objBlock
If TypeOf ent Is AcadExternalReference Then
Set objBlockRef = ent
msg = msg & objBlockRef.Name & " | " & objBlockRef.Path & vbCrLf
End If
Next ent
Next objLayout
MsgBox msg, vbInformation, "Xref paths by RLB"
End Sub

richard.binning
2004-06-25, 05:29 PM
Use the TypeOf method and look for "AcadExternalReference"

Marshal_Rosenberg60828
2004-06-25, 10:16 PM
Hi Richard,

I ran the File Depenency code (acutally, a Foxpro version) against the sample, and came up with the same results...However, I'm curious about something:

Why are the previous XREF dependencies listed even though the XRef Manager only shows the last one?

richard.binning
2004-06-30, 02:46 AM
I'm not sure, perhaps the XRefs were deleted instead of being detached.