Trying to repath xrefs using AcadDbx
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Trying to repath xrefs using AcadDbx
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA

Author Message
Guest






Posted: Sun Nov 06, 2005 9:10 pm    Post subject: Trying to repath xrefs using AcadDbx Reply with quote

I can successfully recurse all the xrefs from a main drawing and copy
all the files to a destination folder. However, I can't seem to update
the path to remove the old folder.

This code runs without error but when I open the main file from its new
location the xrefs are still resolved to their original paths.

Sub PackAndGoTest()
PackAndGo ThisDrawing.FullName, "C:\Temp\"
MsgBox "Done"
End Sub

Sub PackAndGo(strDwgFile As String, strDestFolder As String)
Dim dwgX As New AXDBlib.AxDbDocument
Dim oBlkRef As AcadExternalReference
Dim oEnt As AcadEntity
Dim strPath As String
If fs.GetParentFolderName(strDwgFile) & "\" <> strDestFolder Then
fs.CopyFile strDwgFile, strDestFolder, True
Debug.Print "Copying " & strDwgFile & " to " & strDestFolder
strDwgFile = fs.BuildPath(strDestFolder,
fs.GetFileName(strDwgFile))
End If
dwgX.Open strDwgFile
For Each oEnt In dwgX.ModelSpace
If TypeOf oEnt Is AcadExternalReference Then
Set oBlkRef = oEnt
strDwgFile = oBlkRef.Path
If InStr(strDwgFile, "\") > 0 Then
On Error Resume Next
fs.CopyFile strDwgFile, strDestFolder, True
If Err.Number <> 0 Then
Debug.Print "**Could not find xref " & strDwgFile
Exit Sub
Else
Debug.Print "Copying " & strDwgFile & " to " &
strDestFolder
End If
End If
strDwgFile = fs.BuildPath(strDestFolder,
fs.GetFileName(strDwgFile))
oBlkRef.Path = strDwgFile
oBlkRef.Update
dwgX.Save
'recurse in case of nested xrefs
PackAndGo strDwgFile, strDestFolder
End If
Next
End Sub

Any help appreciated

Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Access Forum - Microsoft Office Forum - Electronics

Contact Us Powered by phpBB