Hi Brandon,
The Add method for a custom table has required parameters and some that are optional. This is from the API help. The parameters with square brackets are optional. Farther below is my iLogic code I used to test. It only uses the required parameters. (same as the VBA code you mentioned)
Syntax
CustomTables.Add( Title As String, PlacementPoint As Point2d, NumberOfColumns As Long, NumberOfRows As Long, ColumnTitles() As String, [Contents] As Variant, [ColumnWidths] As Variant, [RowHeights] As Variant, [MoreInfo] As Variant ) As CustomTable
I don't see a way to add a table using the API without having to provide those required parameters. Also in my tests if the current table style has settings for the columns they can effect the results of the Add method.
Here is the iLogic rule:
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDoc.Document
' Set a reference to the active sheet.
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
If oSheet.CustomTables.count > 0 Then
oSheet.CustomTables.Item(1).Delete()
End If
'Set the column titles & Create the custom table
Dim oInspTblTitle As String
oInspTblTitle = "INSPECTION DIMENSIONS"
Dim oTitles(2) As String
oTitles(0) = "DIMENSION NUMBER"
oTitles(1) = "DESIGN"
oTitles(2) = "ACTUAL"
'oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.TableStyle.HeadingGap = 0.125
'oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.TableStyle.ColumnValueHorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter
Dim oGenDimCount As Integer = 0
Dim oDim As DrawingDimension
For Each oDim In oSheet.DrawingDimensions
If oDim.IsInspectionDimension Then
oGenDimCount = oGenDimCount + 1
End If
Next
Dim oInspDimTable As CustomTable
'oInspDimTable = oSheet.CustomTables.Add(oInspTblTitle, ThisApplication.TransientGeometry.CreatePoint2d(1.5, 27), 3, oGenDimCount, oTitles)
Dim pnt As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(1.5, 27)
oInspDimTable = oSheet.CustomTables.Add(oInspTblTitle, pnt, 3, oGenDimCount, oTitles)
'oInspDimTable = oSheet.CustomTables.Add(oInspTblTitle, pnt, , , oTitles)
'Get Inspection Dimension Data
Dim oInspDim As DrawingDimension 'WB commented
Dim oInspDimShape As InspectionDimensionShapeEnum
Dim oInspDimText As DimensionText
Dim oInspDimText2 As Object
Dim oInspDimNumber As String '= ""
Dim oInspDimRate As String' = ""
Dim i As Integer
Dim oCellInspDimNum As Cell
Dim oCellInspDim As Cell
i = 1
For Each oSheet In oDrawDoc.Sheets
For Each oInspDim In oSheet.DrawingDimensions
If oInspDim.IsInspectionDimension Then
oInspDim.GetInspectionDimensionData(oInspDimShape, oInspDimNumber, oInspDimRate)
oInspDimText = oInspDim.Text
oInspDimText2 = ThisApplication.UnitsOfMeasure.GetPreciseStringFromValue(oInspDim.ModelValue, UnitsTypeEnum.kInchLengthUnits)
oCellInspDimNum = oInspDimTable.Rows.Item(i).Item("DIMENSION NUMBER")
oCellInspDimNum.Value = oInspDimNumber
oCellInspDim = oInspDimTable.Rows.Item(i).Item("DESIGN")
oCellInspDim.Value = oInspDimText2
i = i + 1
End If
Next
Next
oInspDimTable.Sort("DIMENSION NUMBER", True)
Dim oRow As Row
For Each oRow In oInspDimTable.Rows
If oCellInspDimNum.Value <> oInspDimNumber Then
oRow.Delete()
End If
Next
Thanks,
Wayne
Wayne Brill
Developer Technical Services
Autodesk Developer Network