Message 1 of 2

Not applicable
10-18-2021
08:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am trying to write a rule that will iterate through an assembly and change the iproperty description for every part. Currently I have the following code:
Dim partTypeString As String = "Part types:" & vbCrLf Dim oDoc As Document = ThisApplication.ActiveDocument Dim aDoc As DocumentsEnumerator = oDoc.AllReferencedDocuments Dim iDoc As Document For Each oRefDoc As Document In ThisDoc.Document.AllReferencedDocuments If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Dim partName As String = oRefDoc.DisplayName Dim partType As String Try partType = TryCast(oRefDoc, PartDocument).ComponentDefinition.Parameters.UserParameters("PartType").Value Catch 'partType = "parameter doesn't exist" 'MessageBox.Show(partType, "Title") End Try For Each iDoc In aDoc Dim sTS As String = iDoc.FullFileName Dim FNamePos As Long = InStrRev(sTS, "\", - 1) Dim docFName As String = Mid(sTS, FNamePos + 1, Len(sTS) - FNamePos) iProperties.Value(docFName, "Project", "Description") = partType Next End If Next
This code is very close, it will go through the entire assembly and changes the part description to the last one in the list, so where the descriptions should all be different they are all the same. I think there is an issue with my for loops where it is over writing the correct description with the last description in the list "partType". Any help on how to correct my for loop?
Solved! Go to Solution.