iLogic For loop Help

iLogic For loop Help

Anonymous
Not applicable
1,459 Views
1 Reply
Message 1 of 2

iLogic For loop Help

Anonymous
Not applicable

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?

 

0 Likes
Accepted solutions (1)
1,460 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Made simple indent error, problem solved

0 Likes