Splitting a HoleTable using API is not possible at present. In this blog post we will look at a workaround that mimics a split HoleTable by creating two HoleTables each of which lists a certain hole information. Please note that this workaround creates two separate HoleTables both of which are unrelated and have Sheet as its parent. In case of splitting a HoleTable using Inventor UI, the split HoleTable is nested under a parent HoleTable. This structure provides the option to un-split the HoleTables at any time, if you need to. Such un-split option would not be available when using the workaround demonstrated in this blog post, as the two HoleTables are unrelated. As the HoleTables are separate and have Sheet as their parent, Inventor would not know that the two tables are related by a split.
Here is a VBA code snippet which should work with the attached drawing. If you are trying it on any other drawing, the index values may need to be modified accordingly.
Dim oDoc As DrawingDocument
Set oDoc = ThisDocument
Dim oSheet As Sheet
Set oSheet = oDoc.Sheets.Item(1)
Dim oDrawingView As DrawingView
Set oDrawingView = oSheet.DrawingViews.Item(2)
'Modify the index to ensure that the right'drawing curve is used to create the intent'For the attached drawing, this will locate 'the origin indicator at the lower left cornerDim oCurve As DrawingCurve
Set oCurve = oDrawingView.DrawingCurves.Item(53)
Debug.Print oCurve.CurveType
Dim oIntent As GeometryIntent
Set oIntent _
= oSheet.CreateGeometryIntent(oCurve, oCurve.StartPoint)
'Create an origin indicatorIfNot oDrawingView.HasOriginIndicator Then
Call oDrawingView.CreateOriginIndicator(oIntent)
EndIf
'Positions of the hole tablesDim oPt1 As Point2d
Set oPt1 _
= ThisApplication.TransientGeometry.CreatePoint2d(35, 45)
Dim oPt2 As Point2d
Set oPt2 _
= ThisApplication.TransientGeometry.CreatePoint2d(55, 45)
'Create a hole table for the drawing viewDim oHoleTable1 As HoleTable
Set oHoleTable1 = oSheet.HoleTables.Add(oDrawingView, oPt1)
Dim oCollection1 As ObjectCollection
Set oCollection1 _
= ThisApplication.TransientObjects.CreateObjectCollection()
Dim oCollection2 As ObjectCollection
Set oCollection2 _
= ThisApplication.TransientObjects.CreateObjectCollection()
'Identify the row to splitDim splitRow AsInteger
Dim rowsCnt AsInteger
rowsCnt = oHoleTable1.HoleTableRows.Count
If rowsCnt Mod 2 = 0 Then
splitRow = rowsCnt / 2
ElsesplitRow = (rowsCnt - 1) / 2
EndIf
'Get the hole curves for creating the hole tablesDim cnt AsInteger
cnt = 1
ForEach oRow In oHoleTable1.HoleTableRows
cnt = cnt + 1
If cnt < splitRow Then
oCollection1.Add oRow.ReferencedHole
ElseoCollection2.Add oRow.ReferencedHole
EndIf
NextoHoleTable1.Delete
'Split hole table - 1Dim oSplitHoleTable1 As HoleTable
Set oSplitHoleTable1 _
= oSheet.HoleTables.AddSelected(oCollection1, oPt1)
'Split hole table - 2Dim oSplitHoleTable2 As HoleTable
Set oSplitHoleTable2 _
= oSheet.HoleTables.AddSelected(oCollection2, oPt2)
'Renumber the second hole table to mimic a split tablecnt = oSplitHoleTable1.HoleTableRows.Count + 1
ForEach oRow In oSplitHoleTable2.HoleTableRows
oRow.Item(1).FormattedText = "A" & CStr (cnt)
cnt = cnt + 1
Next