Access to xref paths in VBA

Access to xref paths in VBA

bdavis-whbengineers
Explorer Explorer
407 Views
1 Reply
Message 1 of 2

Access to xref paths in VBA

bdavis-whbengineers
Explorer
Explorer
I am trying to make a list of all xref paths(including nested) in a drawing session in VBA. I can compile an xref name tree through the .isxref property, but I cn't seem to get the .path property, because Thisdrawing.blocks.Item("xrefname") only returns a block, and thisdrawing.modelspace.Item("xrefname") gives a 'invalid procedure call or argument' error. Any suggestions?

Here is some additional info. I have some code that gets all the xrefs in a drawing and check the path to see if the xref drawing exists. If not it checks known alternates(ie the archive) for the drawing. The program also generates a listing of what is found in an alternate location or what isn't found anyplace. This code works, but it is iterating through every object in every xrefed drawing looking for xrefs, which is a problem on drawings with a large number of objects. Through the bocks collection I can quickly get the names of the xrefs, whether they are nested and where they are nested(we're talking microseconds vs tens of minutes on a large drawing), but I cant get the xref that the block object is refering to so I can get the standard xref properties. I think I am missing something basic here. Can anyone offer any suggestions?
0 Likes
408 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
You need to define variables with an Acadexternalreference and an Acadentity. Then when you find the xref through the isxref property, set a variable with acadexternalreference = to the acadentity. The acadexternalreference has the .path property you are looking for. Something like this (this is only a snippet of code).



Dim objXref As AcadExternalReference

Dim objBlkRef As AcadBlockReference

Dim objEnt As AcadEntity

Dim objNext As AcadBlock

For Each objEnt In objBlk

If TypeOf objEnt Is AcadBlockReference Then

Set objBlkRef = objEnt

Set objNext = ThisDrawing.Blocks(objBlkRef.Name)

If objNext.IsXRef Then

Set objXref = objEnt

Debug.Print objNext.Name, objXref.Path

End If

End If

Next


0 Likes