Thank you!
Got it.
If anyone needs the code:
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
'Dim oXLFile As String = "C:\TEMP\DrawingDimensions.xlsx"
Dim oSheet As String = "Tabelle1"
Dim oExcel As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim oWB As Microsoft.Office.Interop.Excel.Workbook = oExcel.Workbooks.add'.Open(oXLFile)
Dim oWS As Microsoft.Office.Interop.Excel.Worksheet = oWB.Worksheets.Item(oSheet)
Dim oCells As Microsoft.Office.Interop.Excel.Range = oWS.Cells
'oCells.item(2,1).value= b.Text.Text.ToString
Dim a As Inventor.DrawingDocument = ThisDrawing.Document
Dim s As Inventor.Sheet = a.ActiveSheet
Dim i As Integer = 1
oCells.Item(1,1).value = "Dimension"
oCells.Item(1,2).value = "Tolerance Upper"
oCells.Item(1,3).value = "Tolerance Lower"
For Each b As Inventor.DrawingDimension In s.DrawingDimensions
i = i + 1
'MsgBox (b.Text.Text & " " & b.Tolerance.ToleranceType)
If b.Tolerance.ToleranceType = 31236 Then
oCells.Item(i,1).value = b.Text.Text
oCells.Item(i,2).value = b.Tolerance.Upper*10
oCells.Item(i,3).value = b.Tolerance.Lower*10
' Set Inspection Dimension Data
DrawingDimension.SetInspectionDimensionData(InspectionDimensionShapeEnum, "Label", "Rate")
End If
If b.Tolerance.ToleranceType = 31233 Then
oCells.Item(i,1).value = b.Text.Text
oCells.Item(i,2).value = b.Tolerance.Upper*10
oCells.Item(i,3).value = b.Tolerance.Lower*10
' Set Inspection Dimension Data
DrawingDimension.SetInspectionDimensionData(InspectionDimensionShapeEnum, "Label", "Rate")
End If
If b.Tolerance.ToleranceType = 31235 Then
Dim du As Double = "+" & (b.Tolerance.Upper * 10)
Dim dl As Double = "-" & (b.Tolerance.Upper * 10)
'MsgBox("+"&(b.Tolerance.Upper*10).ToString)
oCells.Item(i,1).value = b.Text.Text
oCells.Item(i,2).value = du '"="+"" &(b.Tolerance.Upper*10)'"p"'"+" & b.Tolerance.Upper*10
oCells.Item(i,3).value = dl'"-" &(b.Tolerance.Lower*10)'"q"'"-" &b.Tolerance.Lower*10
' Set Inspection Dimension Data
DrawingDimension.SetInspectionDimensionData(InspectionDimensionShapeEnum, "Label", "Rate")
End If
If b.Tolerance.ToleranceType = 31246 Then
oCells.Item(i,1).value = (Replace((Replace(b.Text.Text.ToString,"(","")),")",""))'Replace(b.Text.Text.ToString,"-","")
oCells.Item(i,2).value = b.Tolerance.Upper*10
oCells.Item(i,3).value = b.Tolerance.Lower*10
' Set Inspection Dimension Data
DrawingDimension.SetInspectionDimensionData(InspectionDimensionShapeEnum, "Label", "Rate")
End If
Next
' Speichern und Schließen der Arbeitsmappe
oWB.SaveAs("C:\TEMP\"& a.DisplayName & ".xlsx")
oWB.Close()
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports exe = Microsoft.Office.Interop.Excel
Dim oSheet As String = "Tabelle1"
Dim oExcel As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim oWB As Microsoft.Office.Interop.Excel.Workbook = oExcel.Workbooks.Add
Dim oWS As Microsoft.Office.Interop.Excel.Worksheet = oWB.Worksheets.Item(oSheet)
Dim oCells As Microsoft.Office.Interop.Excel.Range = oWS.Cells
Dim a As Inventor.DrawingDocument = ThisDrawing.Document
Dim s As Inventor.Sheet = a.ActiveSheet
Dim i As Integer = 1
oCells.Item(1, 1).Value = "Dimension"
oCells.Item(1, 2).Value = "Tolerance Upper"
oCells.Item(1, 3).Value = "Tolerance Lower"
oCells.Item(1, 4).Value = "Inspection Label"
For Each b As Inventor.DrawingDimension In s.DrawingDimensions
i = i + 1
If b.Tolerance.ToleranceType = 31236 Then
oCells.Item(i, 1).Value = b.Text.Text
oCells.Item(i, 2).Value = b.Tolerance.Upper * 10
oCells.Item(i, 3).Value = b.Tolerance.Lower * 10
End If
If b.Tolerance.ToleranceType = 31233 Then
oCells.Item(i, 1).Value = b.Text.Text
oCells.Item(i, 2).Value = b.Tolerance.Upper * 10
oCells.Item(i, 3).Value = b.Tolerance.Lower * 10
End If
If b.Tolerance.ToleranceType = 31235 Then
Dim du As Double = "+" & (b.Tolerance.Upper * 10)
Dim dl As Double = "-" & (b.Tolerance.Upper * 10)
oCells.Item(i, 1).Value = b.Text.Text
oCells.Item(i, 2).Value = du
oCells.Item(i, 3).Value = dl
End If
If b.Tolerance.ToleranceType = 31246 Then
oCells.Item(i, 1).Value = Replace(Replace(b.Text.Text.ToString, "(", ""), ")", "")
oCells.Item(i, 2).Value = b.Tolerance.Upper * 10
oCells.Item(i, 3).Value = b.Tolerance.Lower * 10
End If
' Get Inspection Label
Dim inspectionLabel As String = ""
If b.IsInspectionDimension() Then
Dim shape As Inventor.InspectionDimensionShapeEnum
Dim label As String = ""
Dim rate As String = ""
b.GetInspectionDimensionData(shape, label, rate)
inspectionLabel = label
End If
oCells.Item(i, 4).Value = inspectionLabel
Next
' Save and close the workbook
oWB.SaveAs("C:\TEMP\" & a.DisplayName & ".xlsx")
oWB.Close()