Inventor inspection sheet auto populate dimensions and replacing with relative location letters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, i am trying to write a rule with Inventor iLogic 2023 to create an inspection table that takes dimensions or annotations from the sheet and auto populates a table with them, when I run the code it is saying Public member 'Tables' on type 'Sheet' not found. how would I go about fixing this code. I am relatively new at coding
my current code is
Imports Inventor
Imports Inventor.Text
Imports Inventor.Drawing
Imports Inventor.Annotation
Sub Main()
'Get active document and current sheet
Dim doc As DrawingDocument = ThisApplication.ActiveDocument
Dim sheet As Sheet = doc.ActiveSheet
'Create new table
Dim oCustomTable As CustomTable = sheet.CustomTables.Add("MyTable", sheet.CenterBlock.Position, 4, 1, {"Location", "Dimension", "As Built", "Inspected"})
'Add rows to table for each dimension set
Dim index As Integer = 1
For Each dimSet As DimensionSet In sheet.DimensionSets
Dim location As String = GetLocationName(index)
Dim asBuilt As String = ""
Dim inspected As String = ""
'Get dimensions from dimension set
For Each dim As Dimension In dimSet.OfType(Of Dimension)()
'Get dimension value
Dim value As String = dim.Parameter.ValueAsString
'Add dimension to table row based on its text
Select Case dim.Text
Case "As Built"
asBuilt = value
Case "Inspected"
inspected = value
Case Else
oCustomTable.Resize(oCustomTable.Rows.Count + 1, oCustomTable.Columns.Count)
oCustomTable.Cell(oCustomTable.Rows.Count, 1).Value = location
oCustomTable.Cell(oCustomTable.Rows.Count, 2).Value = value
End Select
Next
'Add row to table for "As Built" dimension
oCustomTable.Resize(oCustomTable.Rows.Count + 1, oCustomTable.Columns.Count)
oCustomTable.Cell(oCustomTable.Rows.Count, 1).Value = location
oCustomTable.Cell(oCustomTable.Rows.Count, 3).Value = asBuilt
'Add row to table for "Inspected" dimension
oCustomTable.Resize(oCustomTable.Rows.Count + 1, oCustomTable.Columns.Count)
oCustomTable.Cell(oCustomTable.Rows.Count, 1).Value = location
oCustomTable.Cell(oCustomTable.Rows.Count, 4).Value = inspected
index += 1
Next
'Delete all dimensions from sheet
For Each dim As Dimension In sheet.DimensionConstraints.OfType(Of Dimension)()
dim.Delete()
Next
'Replace text in dimensions with letters
index = 1
For Each dimSet As DimensionSet In sheet.DimensionSets
For Each dim As Dimension In dimSet.OfType(Of Dimension)()
Dim letter As String = GetLetter(index)
Dim text As TextBox = Nothing
Dim position As Point2d = dim.CenterPoint
'Add new text box with letter
text = sheet.TextBoxes.Add(position, letter)
text.Style = doc.Styles.GeneralNoteStyle
text.ScaleMode = TextScaleModeEnum.kFitScale
text.FitDirection = TextFitDirectionEnum.kFitHorizontal
index += 1
Next
Next
End Sub
Function GetLocationName(index As Integer) As String 'Get alphabet character for index (1=A, 2=B, etc.) Dim character As Char = Chr(64 + index)
'If character is beyond "Z", append "A" to result and decrement index
If character = "["c Then index -= 26 character = "A"c
End If
'Return character or character pair for index
If index > 26 Then
Return GetLocationName(Int((index - 1) / 26)) & character
Else