Message 1 of 17
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to right some code to check an assembly for old revision parts. We don't use Vault or any sort of PDM so when we up issue a part it gets placed into a sub folder call "OldIssues".
I have written some code which cycles through each referenced document in the assembly and checks to see if it's in the OldIssues folder, if it is than the user gets the option to replace it with the latest issue. What I need to get is the first occurrence of the out of date component to be able to use the Component.Replace function.
Please see code below;
Any help would be greatly appreciated.
Thanks, Nathan
'get the active assembly document Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim oDoc As Document 'cycle through all referenced documents For Each oDoc In oAsmDoc.ReferencedDocuments 'remove file extension from file name oExtPosn = InStrRev(oDoc.DisplayName, ".", -1) oFName = Left(oDoc.DisplayName, oExtPosn -1) 'get current folder name oNamePosn = InStrRev(oDoc.FullFileName, "\", -1) oFilePath = Left(oDoc.FullFileName, oNamePosn - 1) oFolderPosn = InStrRev(oFilePath, "\", -1) oFolderName = Right(oFilePath, Len(oFilePath) - oFolderPosn) 'if document is in "OldIssues" folder then it must be out of date If oFolderName = "OldIssues" Then 'remove "OldIssues" from folder path oFilePath2 = Left(oDoc.FullFileName, oNamePosn - 10) 'confirm users wants to replace old issue oChoice = MessageBox.Show(oFName & " is out of date." + vbCrLf + "Would you like to replace it?", "Replace Document", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If oChoice = 7 Then 'do nothing Else 'replace old issue with latest 'Component.Replace(????, "OtherPartfilename.ipt", True) End If InventorVb.DocumentUpdate() End If InventorVb.DocumentUpdate() Next
Solved! Go to Solution.