that work on an drawing . but I like to run it on a all the drawing on an assembly
somthing like this... I know the code does not work. but is there a way to find
'Test code
Dim a As Inventor.DrawingDocument = oFS2.GetFile(Left(brow.ReferencedFileDescriptor.FullFileName, Len(brow.ReferencedFileDescriptor.FullFileName) -4) & ".idw")
Dim s As Inventor.Sheet = a.ActiveSheet
Dim pl As Inventor.PartsList = s.PartsLists.Item(1)
Dim q As Integer = 0
q = 0
For Each r As Inventor.PartsListRow In pl.PartsListRows
If r.Ballooned = False Then
q = q +1
End If
'MsgBox(r.Ballooned)
Next
'If q <> 0 Then
GoExcel.CellValue(ExcelFile, ExcelSheet, "K" & Row2) = q
'MsgBox (q & " items are not ballooned")
'End If
' End test code
This is my complet code
Class BOMEXport
Shared Row2 As Integer = 3
Shared oDate1 As DateTime
Shared oDate2 As DateTime
Shared oToday As DateTime
Sub main
Row2 =3
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
oBOM.StructuredViewDelimiter = "."
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Structured")
debug("Call ExportToExcel")
Call ExportToExcel(oBOMView.BOMRows)
debug(GoExcel.ToString)
debug("save excel file")
GoExcel.Save
GoExcel.Close
End Sub
Public Function ExportToExcel(brows As BOMRowsEnumerator)
'Dim Row2 As Integer
Try
If Row2 ❤️ Then
End If
Catch
end try
ExcelFile = "C:\Working Folder\CAD\Kallesoe\Kallesoe iLogic\Underdevelopment\ReviewDrawing.xlsx"
ExcelSheet = "CompleteDataSet"
GoExcel.Open(ExcelFile, ExcelSheet)
Dim brow As BOMRow
For Each brow In brows
Dim rDoc As Document
rDoc = brow.ComponentDefinitions.Item(1).Document
Dim docPropertySet As PropertySet
docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties")
Dim docPropertySet1 As PropertySet
docPropertySet1 = rDoc.PropertySets.Item("User Defined Properties")
Dim docPropertySet2 As PropertySet
docPropertySet2 = rDoc.PropertySets.Item("User Defined Properties")
'item , part number, qty, description, G_L (Custom), Raw material, Status (Custom)
Try
debug(brow.ItemNumber & " Row nr " & Row2)
GoExcel.CellValue(ExcelFile, ExcelSheet, "B" & Row2) = brow.ItemNumber
Catch
End Try
Try
GoExcel.CellValue(ExcelFile, ExcelSheet, "C" & Row2) = docPropertySet.Item("Part Number").Value
Catch
end try
Try
Dim strFileName As String
Dim oFS As Object
strFileName = brow.ReferencedFileDescriptor.FullFileName
oFS = CreateObject("Scripting.FileSystemObject")
'Dato for hvornår den sidste er blevet ændret
oDate1 = oFS.GetFile(strFileName).DateLastModified
GoExcel.CellValue(ExcelFile, ExcelSheet, "D" & Row2) = oDate1
Catch
End Try
Try
GoExcel.CellValue(ExcelFile, ExcelSheet, "U" & Row2) = docPropertySet.Item("Description").Value
Catch
End Try
Dim oFS2 As Object
oDate2 = Nothing
oFS2 = CreateObject("Scripting.FileSystemObject")
Try
oDate2 = oFS2.GetFile(Left(brow.ReferencedFileDescriptor.FullFileName, Len(brow.ReferencedFileDescriptor.FullFileName) -4) & ".idw").DateLastModified
GoExcel.CellValue(ExcelFile, ExcelSheet, "F" & Row2) = "Yes"
Catch
oDate2 = Nothing
GoExcel.CellValue(ExcelFile, ExcelSheet, "F" & Row2) = "No"
End Try
'Test code
Dim a As Inventor.DrawingDocument = oFS2.GetFile(Left(brow.ReferencedFileDescriptor.FullFileName, Len(brow.ReferencedFileDescriptor.FullFileName) -4) & ".idw")
Dim s As Inventor.Sheet = a.ActiveSheet
Dim pl As Inventor.PartsList = s.PartsLists.Item(1)
Dim q As Integer = 0
q = 0
For Each r As Inventor.PartsListRow In pl.PartsListRows
If r.Ballooned = False Then
q = q +1
End If
Next
GoExcel.CellValue(ExcelFile, ExcelSheet, "K" & Row2) = q
' End test code
GoExcel.CellValue(ExcelFile, ExcelSheet, "E" & Row2) = oDate2
If oDate2 < oDate1 Or oDate2 = Nothing Then
GoExcel.CellValue(ExcelFile, ExcelSheet, "G" & Row2) = "No"
Else
GoExcel.CellValue(ExcelFile, ExcelSheet, "G" & Row2) = "Yes"
End If
GoExcel.CellValue(ExcelFile, ExcelSheet, "I" & Row2) = right(brow.ReferencedFileDescriptor.FullFileName,3) ' extension
'find docPropertySet.Item("Description").Value
Try
If docPropertySet.Item("Description").Value = docPropertySet1.Item("Part Description").Value Then
GoExcel.CellValue(ExcelFile, ExcelSheet, "J" & Row2) = "No"
Else If docPropertySet.Item("Description").Value <> docPropertySet1.Item("Part Description").Value And docPropertySet.Item("Description").Value = "J" & Row2 <> ""
GoExcel.CellValue(ExcelFile, ExcelSheet, "J" & Row2) = "Yes"
End If
Catch
If docPropertySet.Item("Description").Value = "" Then
GoExcel.CellValue(ExcelFile, ExcelSheet, "J" & Row2) = "No"
Else
GoExcel.CellValue(ExcelFile, ExcelSheet, "J" & Row2) = "yes"
End If
End Try
debug("Item nr. " & brow.ItemNumber)' & "part number " &docPropertySet.Item("Part Number").Value & "qty " & brow.ItemQuantity & "description " & docPropertySet.Item("Description").Value & "Length " & docPropertySet1.Item("G_L").Value & "Raw Material " & docPropertySet1.Item("Raw Material").Value & "Status " &docPropertySet1.Item("Status").Value)
Row2 = Row2 + 1
If Not brow.ChildRows Is Nothing
Call ExportToExcel(brow.ChildRows)
End If
Next
End Function
Public Sub debug(txt As String)
Trace.WriteLine("NTI : " & txt)
End Sub
End Class