Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
In an assembly we have to Save and Replace all referenced documents.
Very briefly: in Factory Design every inserted asset is getting a very long code in the File Name. We need short names.
And for every asset we need an unique filenumber, codes in FDU are not unique even thought it seems so..
I wrote the following code (every thing works, except the SaveAndReplace at the end) but I get the following error message.
Who knows what to do?
InvDoc = ThisDoc.Document
Dim oRefDocs As DocumentsEnumerator = InvDoc.AllReferencedDocuments
Dim oRefDoc As Document
For Each oRefDoc In oRefDocs
'Only filenames without $
Dim oNameCheck As String = oRefDoc.FullDocumentName
'i = MessageBox.Show(oNameCheck, "document nr", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
If oNameCheck.Contains("$") Then
'Skip it!
Else
Dim oPartNumber As String = oRefDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value
Dim Time As DateTime = DateTime.Now
Dim Format As String = "$yyyymmddThhmmss"
Dim DTG As String = Time.ToString(Format)
'format model file name
'For now a fixed path is given
Dim Folder_Location As String = "C:\VaultWS2\WSP Systems\Factory Assets\"
' 'Assembly
If oRefDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
Dim oNewFileName As String = Folder_Location & DTG & "_" & oPartNumber & ".iam"
' i = MessageBox.Show(oNewFileName, "nieuwe naam assy", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
' 'Part
ElseIf oRefDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then
Dim oNewFileName As String = Folder_Location & DTG & "_" & oPartNumber & ".ipt"
' i = MessageBox.Show(oNewFileName, "nieuwe naam prt", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
End If
End If
' 'Save And Replace
oRefDoc.Document.SaveAs(oNewFileName, True)
FileChange = True
Next
iLogicVb.UpdateWhenDone = True
Solved! Go to Solution.