Message 1 of 7
Changing an xref path - the whole path??

Not applicable
02-04-2005
09:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been searching on this for days and I've found many helpful and diverse ways to identify xrefs, detach them, attach them and to identify the file name.
What I can't seem to figure out is how to get the preceeding directory structure aka the entire path. Does anyone have a snippet that will show me what I need to do to get the entire path? I've read the issue may be that you have to get the path from the XREF OBJECT, not the BLOCK OBJECT. How would one go about that?
Here's what I've been working with so far (I believe it came from Gordon Price):
Dim oXref As AcadExternalReference
Private Sub CommandButton1_Click()
GetXrefPathByBlockName ("fptcprfapm") ' This is an example xref I have attached to my drawing. "X:\TEST\Subfolder\fptcprfapm.dwg"
Label1.Caption = oXref.Path ' This just returns "ftpcprfapm.dwg"
End Sub
Public Function GetXrefPathByBlock(oBlock As AcadBlock) As String
'returns the path of the xref
Dim oXref As AcadExternalReference
Dim obj As Object
If oBlock.IsXRef Then
For Each obj In ThisDrawing.ModelSpace
If TypeOf obj Is AcadExternalReference Then
Set oXref = obj
If oXref.Name = oBlock.Name Then
GetXrefPathByBlock = oXref.Path
End If
End If
Next obj
For Each obj In ThisDrawing.PaperSpace
If TypeOf obj Is AcadExternalReference Then
Set oXref = obj
If oXref.Name = oBlock.Name Then
GetXrefPathByBlock = oXref.Path
End If
End If
Next obj
Else
GetXrefPathByBlock = ""
End If
End Function
Public Function GetXrefPathByBlockName(BlockName As String) As String
'returns the path of the xref
Dim obj As Object
For Each obj In ThisDrawing.ModelSpace
If TypeOf obj Is AcadExternalReference Then
Set oXref = obj
If oXref.Name = BlockName Then
GetXrefPathByBlockName = oXref.Path
Else
GetXrefPathByBlockName = ""
End If
End If
Next obj
For Each obj In ThisDrawing.PaperSpace
If TypeOf obj Is AcadExternalReference Then
Set oXref = obj
If oXref.Name = BlockName Then
GetXrefPathByBlockName = oXref.Path
Else
GetXrefPathByBlockName = ""
End If
End If
Next obj
End Function
Public Function vbdPowerSet(strName As String) As AcadSelectionSet
Dim objSelSet As AcadSelectionSet
Dim objSelCol As AcadSelectionSets
Set objSelCol = ThisDrawing.SelectionSets
For Each objSelSet In objSelCol
If objSelSet.Name = strName Then
objSelCol.Item(strName).Delete
Exit For
End If
Next
Set objSelSet = objSelCol.Add(strName)
Set vbdPowerSet = objSelSet
End Function