0

I want to set a table autofit in Catia drawing. But I can't find any command. I'm looking forward to getting some guidance. Thanks

[enter image description here]

There is my simple code.

Dim oDoc As Document
    Dim oView As DrawingView
    Dim oTable As DrawingTables
    
    Set oDoc = CATIA.ActiveDocument
    Set oSheets = oDoc.Sheets
    Set oViews = oSheets.ActiveSheet.Views
    Set oView = oViews.ActiveView
    Set oTable = oView.Tables

    For i = 1 To oTable.Count
        'Debug.Print oneTab.Name
        'oTable.Item(i).AnchorPoint = CatTableBottomRight
    Next
Yume
  • 11
  • 4

1 Answers1

1

By setting the row size and the column size to 0, auto-fit is activated.

Set oTables = oView.Tables

For i = 1 To oTables.Count
   Set oTable = oTables.Item(i)
   for j = 1 to oTable.NumberOfRows
      oTable.SetRowSize j, 0
   next
   for j = 1 to oTable.NumberOfColumns
      oTable.SetColumnSize j, 0
   next
next
Shrotter
  • 350
  • 3
  • 9
  • Thanks for the reply. I tried, it doesn't work with all tables. And it takes a lot of time to complete. – Yume May 13 '22 at 08:05
  • What is special on this not working tables? Maybe you accelerate the script by switching the _ComputeMode_ off during _setrowsize_/_setcolumnsize_. – Shrotter May 13 '22 at 08:34
  • When i switch the Computer Mode off, runtime is greatly improved. The table is created with Bill of material. And after the code runs, the first table does not change. I don't know why! – Yume May 13 '22 at 09:06