Move a hole table to a new sheet

Move a hole table to a new sheet

Anonymous
Not applicable
896 Views
1 Reply
Message 1 of 2

Move a hole table to a new sheet

Anonymous
Not applicable

Hello,

I am looking for a way to move a hole table from one sheet to another via the API. I currently have code that creates a hole table and positions it on a sheet that also contains the flat file view of the part. The problem is the hole table can sometimes overlap with the part, so I would like to move it. I know it can be done in the tree by clicking and dragging the hole table to the new sheet. I have tried reorder the browser nodes but get errors. 

0 Likes
897 Views
1 Reply
Reply (1)
Message 2 of 2

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Unfortunately, Inventor API does not support to copy HoleTable from one sheet to another. But using content of HoleTable, custom table can be created at second sheet.

 

Hoping that below VBA code would help to copy contents of HoleTable from one sheet to another sheet.

 

Public Sub Create_HoleTable()
    
    Dim oDOc As DrawingDocument
    Set oDOc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDOc.Sheets.Item(1)
    
    Dim oHoleTable As HoleTable
    Set oHoleTable = oSheet.HoleTables.Item(2)
        
    Dim copySheet As Sheet
    Set copySheet = oDOc.Sheets.Item(2)
    
    Dim oTitles(1 To 4) As String
    oTitles(1) = oHoleTable.HoleTableColumns.Item(1).Title
    oTitles(2) = oHoleTable.HoleTableColumns.Item(2).Title
    oTitles(3) = oHoleTable.HoleTableColumns.Item(3).Title
    oTitles(4) = oHoleTable.HoleTableColumns.Item(4).Title
    
    Dim oTB As CustomTable
    Set oTB = copySheet.CustomTables.Add(oHoleTable.Title, ThisApplication.TransientGeometry.CreatePoint2d(copySheet.Width - 10, copySheet.Height - 3), 4, 4, oTitles)
    oTB.DataTextStyle.Font = "AIGDT"
    Dim oRow As Row
    For Each oRow In oTB.Rows
        oRow.Delete
    Next
    
    Dim oContents(1 To 4) As String
    Dim oHoleRow As HoleTableRow
    For Each oHoleRow In oHoleTable.HoleTableRows
        oContents(1) = oHoleRow.Item(1).Text
        oContents(2) = oHoleRow.Item(2).Text
        oContents(3) = oHoleRow.Item(3).Text
        oContents(4) = oHoleRow.Item(4).Text
                 
        Call oTB.Rows.Add(0, False, oContents)
    Next
    
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes