split table

split table

ChrisAtherton
Advocate Advocate
595 Views
2 Replies
Message 1 of 3

split table

ChrisAtherton
Advocate
Advocate

Quick question:

 

I cant see it in the API but does anyone know away of seeing if a custom table on a drawing is split and at which row?

 

Thanks

Chris Atherton
IEng MIMechE BEng Hons
Design Automation Services Manager | Symetri
https://uk.linkedin.com/in/chrissoathe
0 Likes
596 Views
2 Replies
Replies (2)
Message 2 of 3

YuhanZhang
Autodesk
Autodesk

You can use below VBA to get query if a custom table is split:

 

Sub CustomTableSplitData()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    ' In UI you select a custom table first
    Dim oTable As CustomTable
    Set oTable = oDoc.SelectSet(1)
    
    On Error Resume Next
    
    ' iNum is sections count
    Dim iNum As Long: iNum = 0
    iNum = oTable.NumberOfSections
    
    If iNum = 1 Then
        MsgBox "The custom table is not split!"
        End
    End If
    
    If iNum > 1 Then
        Dim lRowsOfEachSection As Long
        Dim dNum As Double, dTest As Double
        dNum = oTable.Rows.Count
        dTest = oTable.Rows.Count / iNum
                   
        lRowsOfEachSection = oTable.Rows.Count / iNum
            
        If (dTest - lRowsOfEachSection) >= 0.5 Then
            lRowsOfEachSection = lRowsOfEachSection + 1
        End If
        
        If Not oTable.WrapLeft Then
            MsgBox "The custom table is split into " & iNum & " sections:" & vbCrLf _
                 & "The left section has " & lRowsOfEachSection & " rows."
            End
        Else
            lRowsOfEachSection = oTable.Rows.Count - lRowsOfEachSection * (iNum - 1)
            MsgBox "The custom table is split into " & iNum & " sections:" & vbCrLf _
                 & "The left section has " & lRowsOfEachSection & " rows."
            End
        End If
    End If
    
    Dim lMaxRows As Long: lMaxRows = 0
    lMaxRows = oTable.MaximumRows
        
    If lMaxRows = 0 Then
        MsgBox "The custom table is not split!"
        End
    Else
        iNum = oTable.Rows.Count / lMaxRows
        If iNum * lMaxRows < oTable.Rows.Count Then iNum = iNum + 1
            
        If Not oTable.WrapLeft Then
            MsgBox "The custom table is split into " & iNum & " sections:" & vbCrLf _
                 & "The left section has " & lMaxRows & " rows."
        Else
            Dim lLeftSectionRows As Long
            lLeftSectionRows = oTable.Rows.Count - lMaxRows * (iNum - 1)
            MsgBox "The custom table is split into " & iNum & " sections:" & vbCrLf _
                 & "The left section has " & lLeftSectionRows & " rows."
        End If
    End If
End Sub

 

Hope this helps.

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 3

ChrisAtherton
Advocate
Advocate

Hi and thanks for that.

 

Reading through the code my understanding is that this will tell me if the table has been "split at row" ... this is different to doing a split table which creates a seperate table?  Is that right?

 

Thanks Chris

Chris Atherton
IEng MIMechE BEng Hons
Design Automation Services Manager | Symetri
https://uk.linkedin.com/in/chrissoathe
0 Likes