Hi @sultan_mustun. Here is another example that I somewhat customized to your specs. I had an interest in something similar to this myself recently, so this is sort of exploratory for me too. It will not create the third column though, because I had no idea how to populate that third column based on available data in your post. It expects that you have a drawing open on your screen, and the active sheet has at least one view of an assembly on it. If not, it will not do anything. It will then attempt to navigate only the top level components in that view's referenced assembly, and collect 'instance property' data related to your inquiry specs, but just names and quantities (quantity not based on BOM qty). If it found some matching data, it will then attempt to either find an existing CustomTable by the Title "Instance Data" (can be changed in code), or create a new one. Then it will attempt to put the new data into that table's rows. I have not tested this myself yet, because I was in a hurry and on my way out for the day, so let me know how it works for you.
Sub Main
Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
If oDDoc Is Nothing Then
Logger.Debug("iLogic rule '" & iLogicVb.RuleName & "' was aborted - no DrawingDocument found.")
Return
End If
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
If oSheet.DrawingViews.Count = 0 Then Return
Dim oRefDocDesc As DocumentDescriptor = oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor
If oRefDocDesc.ReferencedDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Return
Dim oInstanceData As New Dictionary(Of String, Integer)
Dim oRefADoc As AssemblyDocument = oRefDocDesc.ReferencedDocument
Dim oOccs As ComponentOccurrences = oRefADoc.ComponentDefinition.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
If Not oOcc.OccurrencePropertySetsEnabled Then Continue For
For Each oProp As Inventor.Property In oOcc.OccurrencePropertySets.Item(1)
If oProp.Name <> "Nozzle_Name" Then Continue For
Dim sNozzleName As String = oProp.Value
If oInstanceData.ContainsKey(sNozzleName) Then
oInstanceData.Item(sNozzleName) += 1 'adds 1 to current Qty value
Else 'this instance name not encountered yet
oInstanceData.Add(sNozzleName, 1) 'add an entry for this name, with Qty = 1
End If
Next oProp
Next oOcc
If oInstanceData.Count = 0 Then Return
Dim oCTable As CustomTable = Nothing
Dim sTitle As String = "Instance Data"
Try : oCTable = oSheet.CustomTables.OfType(Of Inventor.CustomTable).First(Function(c) c.Title = sTitle)
Catch : End Try
If oCTable Is Nothing Then
Dim oP2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width / 2, oSheet.Height / 2)
Dim iCols As Integer = 2
Dim iRows As Integer = oInstanceData.Count
Dim oColTitles() As String = {"Nozzle Name", "QTY"}
Try
oCTable = oSheet.CustomTables.Add(sTitle, oP2D, iCols, iRows, oColTitles)
oCTable.HeadingPlacement = HeadingPlacementEnum.kHeadingAtTop
oCTable.ShowTitle = False
Catch
Logger.Error("Error creating CustomTable.")
End Try
End If
If oCTable Is Nothing Then Return
oCTable.HeadingPlacement = HeadingPlacementEnum.kHeadingAtTop
For i As Integer = 1 To oCTable.Rows.Count
Dim oRow As Inventor.Row = oCTable.Rows.Item(i)
oRow.Item(1).Value = oInstanceData.ElementAt(i - 1).Key
oRow.Item(2).Value = oInstanceData.ElementAt(i - 1).Value
Next i
oSheet.Update
If oDDoc.RequiresUpdate Then oDDoc.Update2(True)
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)