Hi Guys, hope you are all well.
I am just wondering what is the best way to copy files over that are linked together.
What I currently have is the following file structure
These are used as templates which I want to then copy over to a new tooling file and modify.
Part 2 has a linked variable to part1.
I am using the revision manager copy to firstly copy then draft file over to the new folder then using the linked documents to loop through all the lined documents to copy those files.
Then I open the assembly and get the linked documents and then replace the parts files (they are still linked to the templates) with the newly copied part files.
This works quite nicely except that part2 copied still has it linked to the part1 template part file due to the variable link.
I am wondering if there is a way to alter the parent document so it points to the new part1 file or is there a better way to copy the files that will change the link to the new part1 file.
I hope this make sense and below is my code I currently have.
Public Sub copyTemplate(ByVal newFileLoc As String, ByVal comptNo As String, ByVal toolingStage As String) Dim linkedDocName As String newFileLoc = newFileLoc objRevision = New RevisionManager.Application objRevManDoc = objRevision.Open(My.Settings.tempFileLoc & "\" & toolingStage & ".dft") objRevManDoc.Copy(newFileLoc & "\" & comptNo & "-Blank.dft") ' & "Blank.dft") objRevManDoc = Nothing objRevManDoc = objRevision.Open(newFileLoc & "\" & comptNo & "-" & toolingStage & ".dft") objLinkedDocs = objRevManDoc.LinkedDocuments For Each Me.objLinkedItems In objLinkedDocs linkedDocName = System.IO.Path.GetFileName(objLinkedItems.FullName
) objLinkedItems.Copy(newFileLoc & "\" & comptNo & "-" & linkedDocName) Debug.WriteLine(objLinkedItems.LinkedDocuments) 'Debug.WriteLine(System.IO.Path.GetFileName(linked DocName)) Next 'open the assembly file and change the part files linked to it objLinkedDocs = Nothing objRevManDoc = Nothing objRevManDoc = objRevision.Open(newFileLoc & "\" & comptNo & "-" & toolingStage & ".asm") objLinkedDocs = objRevManDoc.LinkedDocuments For Each Me.objLinkedItems In objLinkedDocs linkedDocName = System.IO.Path.GetFileName(objLinkedItems.FullName ) objLinkedItems.Replace(newFileLoc & "\" & comptNo & "-" & linkedDocName) Debug.WriteLine(objLinkedItems.Parent) Debug.Write(linkedDocName) 'TODO: work out why the links are not changing to the new files Next MessageBox.Show("finished") End Sub
Thanks in advance for any help you can give me.
Posted by: Craig Brunton
Post date: 4/18/2012 11:05:59 AM
I actually have the same problem right now like you had a while ago - trying to change the path to the linked documents after copying them elsewhere, which works perfectly for assemblies and parts but doesnt seem to work for drafts. Have you found a solution to that? if yes, can you please share it here?
Posted by: Salwadora
Post date: 1/14/2013 8:15:48 AM
Hi, No sorry I have not yet found a solution to this. l have not done much programming recently but will be doing Some Soon so will be looking at this again and if I find a solution I Will make Sure I post it in this' thread. Cheers Craig Sent from my GT-N7100 using Tapatalk 2
Posted by: Craig Brunton
Post date: 1/20/2013 7:58:41 AM