Message 1 of 24
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm looking for some help on iLogic to create a custom table on a drawing after looking through the assembly of parts and sub assembly iProperties to find any that have the value ACC in the cost center. Then it will put the stock number of those files in the custom table to show that those are the accessories required for the full assembly. I was able to find this code from Clint Brown that can take an assembly and put it in a text file but I'd like to try and stream line it and possibly put the quantity of accessories needed in the table as well.
Sub Main()
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Dim oAppend As System.IO.StreamWriter
oAppend = IO.File.AppendText("C:\Temp\iProperties.txt")
oAppend.WriteLine("ACCESSORY LIST: " & ThisDoc.PathAndFileName(True))
oAppend.Flush()
oAppend.Close()
Call Iterate(oAsmDoc.ComponentDefinition.Occurrences, 1)
End Sub
Private Sub Iterate(Occurrences As ComponentOccurrences, Level As Integer)
'Iterate through Assembly
Dim oOcc As ComponentOccurrence
For Each oOcc In Occurrences
'Find Parts in Assembly
Dim oPart As String
oPart = oOcc.Name
Try
'Write iProps to Parts
If iProperties.Value(oPart,"Design Tracking Properties", "Cost Center") = "ACC" Then
oInfo = iProperties.Value(oPart, "Design Tracking Properties", "Stock Number") & " - " & iProperties.Value(oPart,"Design Tracking Properties", "Cost Center")
'____Open and append to an existing text file_______
Dim oAppend As System.IO.StreamWriter
oAppend = IO.File.AppendText("C:\Temp\iProperties.txt")
oAppend.WriteLine(oInfo)
oAppend.Flush()
oAppend.Close()
End If
Catch
MessageBox.Show("Something went wrong", "Check your assembly")
End Try
'Run through the sub assemblies
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call Iterate(oOcc.SubOccurrences, Level + 2)
End If
Next
End Sub
Solved! Go to Solution.