01-16-2023
09:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-16-2023
09:19 AM
Ive modified this code. Perhaps its useful to someone else?
It will update all rev tables across all sheets.
It will update the rev table style to match the styles library
It will quit if it detects the script has already been run.
Sub Main()
'Check if drawing
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.", vbOKOnly + vbCritical, "Don't worry, Rodney. This time next year, we'll be millionaires!")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oTitle As String = "LEGACY REVISION HISTORY"
Dim oTable As CustomTable
'Stops the iLogic running if Legacy revision history exists.
Dim oExists As Boolean 'false by default
If oSheet.CustomTables.Count > 0 Then
For Each oCTbl As CustomTable In oSheet.CustomTables
If oCTbl.Title = oTitle Then
End If
Next
Exit Sub
End If
Dim oRevTbl As RevisionTable = oSheet.RevisionTables.Item(1)
Dim oPos As Point2d = oRevTbl.Position
'Alternative insertion position off page.
'Dim oPos As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(0,0)
Dim oRowCount As Integer = oRevTbl.RevisionTableRows.Count
Dim oColCount As Integer = oRevTbl.RevisionTableColumns.Count
Dim oCellCount As Integer = oRowCount * oColCount
Dim oColTitles(oColCount - 1) As String
Dim oColWidths(oColCount - 1) As Double
Dim oRowHeights(oRowCount - 1) As Double
Dim oCellContents(oCellCount - 1) As String
Dim oRow, oCol, oCell As Integer
'Get Rvision table information
For oRow = 1 To oRowCount
For oCol = 1 To oColCount
oCellContents(oCell) = oRevTbl.RevisionTableRows.Item(oRow).Item(oCol).FormattedText
oCell = oCell + 1
oColTitles(oCol - 1) = oRevTbl.RevisionTableColumns.Item(oCol).Title
oColWidths(oCol - 1) = oRevTbl.RevisionTableColumns.Item(oCol).Width
Next
oRowHeights(oRow - 1) = oRevTbl.RevisionTableRows.Item(oRow).Height
Next
'Apply to each sheet
For Each oSheet In oDDoc.Sheets
'Remove old revision tables
If oSheet.RevisionTables.Count > 0 Then
For Each oRevTable In oSheet.RevisionTables
oRevTable.Delete
Next
End If
'Insert new legacy revision table
Dim oCTable As CustomTable = oSheet.CustomTables.Add(oTitle, oPos, oColCount, oRowCount, oColTitles, oCellContents, oColWidths, oRowHeights)
'set the table style to match Legacy Revision Table. You need to create a table style in the styles editor, this can be a global style.
Dim oActiveTableStyle As TableStyle
Dim oTableTitle As String
oActiveTableStyle = oDDoc.StylesManager.TableStyles("Legacy Revision Table")
oTableTitle = oActiveTableStyle.Title
oCTable.Style = oActiveTableStyle
Next
End Sub