try this:
Public Class ThisRule
Sub Main()
Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim refDoc As Document = sheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument
Dim infos As New List(Of DocumentInfo)
If (refDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject) Then
If (refDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then
infos.Add(New DocumentInfo(refDoc))
End If
Else
For Each assDoc As Document In refDoc.AllReferencedDocuments
If (assDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject) Then
If (assDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then
infos.Add(New DocumentInfo(assDoc))
End If
End If
Next
End If
If (infos.Count = 0) Then
MsgBox("No sheetmetal found.")
Return
End If
Dim insertPoint = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
Dim headers = New String() {"Part", "Size", "Up", "Down"}
Dim table = sheet.CustomTables.Add("Bends", insertPoint, headers.Length, infos.Count, headers)
For i = 1 To infos.Count
Dim row = table.Rows.Item(i)
Dim info = infos.Item(i - 1)
row.Item(1).Value = info.DisplayName
row.Item(2).Value = info.Size
row.Item(3).Value = info.Ups
row.Item(4).Value = info.Downs
Next
End Sub
End Class
Public Class DocumentInfo
Public Sub New(doc As PartDocument)
Dim uom = doc.UnitsOfMeasure
Dim def As SheetMetalComponentDefinition = doc.ComponentDefinition
Dim flatPattern = def.FlatPattern
For Each result As FlatBendResult In flatPattern.FlatBendResults
If (result.IsOnBottomFace) Then Continue For
If (result.IsDirectionUp) Then
Ups += 1
Else
Downs += 1
End If
Next
Dim width = uom.ConvertUnits(flatPattern.Width, UnitsTypeEnum.kDatabaseAngleUnits, UnitsTypeEnum.kDefaultDisplayAngleUnits)
Dim length = uom.ConvertUnits(flatPattern.Length, UnitsTypeEnum.kDatabaseAngleUnits, UnitsTypeEnum.kDefaultDisplayAngleUnits)
Size = String.Format("{0}x{1}", Math.Round(width, 5), Math.Round(length, 5))
DisplayName = doc.DisplayName
End Sub
Public Property Ups As Integer = 0
Public Property Downs As Integer = 0
Public Property Size As String
Public Property DisplayName As String
End Class
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com