Here is additional sub routines that should achieve a portion of what your looking to do. The cells might populate incorrectly on your end so you may need to adjust the cell number per your revision style. I would suggest you text on a test drawing and adjust the revision style name "Revision Table (ANSI)" as needed.
Unfortunately the auto adjust sheet name wont be possible (at least not easily) as the sheet number is just text and not an updatable formatted text attribute. Putting dynamic names into rev blocks would be best avoided for this very reason.
Public Sub Main
mystart:
Dim view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View")
On Error GoTo myexit
Dim sketch As DrawingSketch = view.Sketches.Add()
Dim cp = sketch.SheetToSketchSpace(view.Position)
Dim blue As Color = ThisApplication.TransientObjects.CreateColor(0, 0, 255)
Dim offSetFromView As Double = 2
sketch.Edit()
oScale = view.Scale
sketch.Name="REVISION CLOUD"
Dim lines = CreateRectangle(sketch, cp, view.Width/oScale + offSetFromView, view.Height/oScale + offSetFromView)
SetLayer(lines, LineTypeEnum.kDashedLineType, 0.05, blue)
sketch.ExitEdit()
Call RevisionBlock(view)
GoTo mystart
myexit :
End Sub
Public Sub SetLayer(lines As SketchEntitiesEnumerator, LineType As LineTypeEnum, LineWeight As Double, color As Color)
For Each line As SketchEntity In lines
Line.Layer.LineType = LineTypeEnum.kDashedLineType
Line.Layer.LineWeight = LineWeight
Line.Layer.Color = color
Next
End Sub
Public Function CreateRectangle(Sketch As DrawingSketch, cp As Point2d, w As Double, h As Double) As SketchEntitiesEnumerator
Dim oTg = ThisApplication.TransientGeometry
Dim p1 As Point2d = cp.Copy()
p1.TranslateBy(oTg.CreateVector2d(w / 2, h / 2))
Dim p3 = p1.Copy()
p3.TranslateBy(oTg.CreateVector2d(-w, -h))
Dim lines = Sketch.SketchLines.AddAsTwoPointRectangle(p1, p3)
Return lines
End Function
Sub RevisionBlock(view As DrawingView)
'Change Revision Table Style
'https://forums.autodesk.com/t5/inventor-customization/ilogic-rule-to-switch-revision-table-sizes-defined-in-styles/td-p/3209372
'https://forums.autodesk.com/t5/inventor-customization/creating-sheet-scope-revision-table-using-ilogic/td-p/6282070
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDrawing.Document
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oTablePt As Point2d = oTG.CreatePoint2d(0, 0)'loosly position Table
Dim oRevTable As RevisionTable
Dim oDoc As Document
oDoc = view.ReferencedDocumentDescriptor.ReferencedDocument
Dim FileName, PN, SN As String
FileName = IO.Path.GetFileName(oDoc.FullDocumentName)
PN = iProperties.Value(FileName, "Project", "Part Number")
SN = oSheet.Name
'Check which revision Table To add, Only needed If Styles are different
oRevStyle = oDrawDoc.StylesManager.RevisionTableStyles.Item("Revision Table (ANSI)")
']
If oSheet.RevisionTables.Count = 1 Then
Call Positiontable(oTablePt,oSheet)
oRevTable = oSheet.RevisionTables.Item(1)
oRevTable.Style = oRevStyle 'Change RevTable Style
Dim oRow As RevisionTableRow
oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count)
booleanParam = InputRadioBox("Pick One", "Continue Editing Current REV", "Add REV",True, Title := "Revision Box Options")'Enter 1st row Contents
If booleanParam = True
RevisionTableContents(oRow,PN,SN)
ElseIf booleanParam = False
Dim oRows As RevisionTableRows = oRevTable.RevisionTableRows
oRows.Add()
oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count)'Get current Row
RevisionTableContents(oRow,PN,SN)
End If
ElseIf oSheet.RevisionTables.Count = 0 Then
Dim oRTBs As RevisionTables
oRTBs = oSheet.RevisionTables
Dim oRTB As RevisionTable 'add a new table
oRTB = oRTBs.Add2(oTablePt, False, True, True, "0" )
Call Positiontable(oTablePt,oSheet)'Position Table after initial insert
oRevTable = oSheet.RevisionTables.Item(1)'get table reference
oRevTable.Style = oRevStyle 'Change RevTable Style
Dim oRow As RevisionTableRow
oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count)
If oRow.IsActiveRow Then
Call RevisionTableContents(oRow,PN,SN)'Enter 1st row Contents
oRTB.UpdatePropertyToRevisionNumber = True 'ensure rev block is set to write to iProperty, This can be modified in two places in the editor and in the template when placing
End If
End If
End Sub
Private Sub Positiontable( oTablePt As Point2d,oSheet As Sheet)
Dim oRevTableItem As RevisionTable
oRevTableItem = oSheet.RevisionTables.Item(1)
Dim oWidthRevTable As Double
oWidthRevTable = oRevTableItem.RangeBox.MaxPoint.X - oRevTableItem.RangeBox.MinPoint.X
Dim oHeightRevTable As Double
oHeightRevTable = oRevTableItem.RangeBox.MaxPoint.Y - oRevTableItem.RangeBox.MinPoint.Y
oTablePt = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Border.RangeBox.MaxPoint.X - oWidthRevTable, oSheet.TitleBlock.RangeBox.MaxPoint.Y + oHeightRevTable)
oRevTableItem.Position = oTablePt
End Sub
']
Sub RevisionTableContents(oRow,PN,SN)
']
'[Revision COL 2
' Dim MyArrayList2 As New ArrayList
' MyArrayList2.Add("AA")
' oArray2 = InputListBox("Select one:", MyArrayList2, "", "iLogic", "Drawn By")
' If oArray2 = "" Then
' Else
' Dim oCell2 As RevisionTableCell = oRow.Item(2)
' oCell2.Text = oArray2
' End If
Dim oCell3 As RevisionTableCell = oRow.Item(3)
'Set it equal to the the current date, date format change from Computer default
oCell3.Text= DateTime.Now.ToString("dd-MM-yyyy")
'[Revision COL 4
Dim MyArrayList4 As New ArrayList
MyArrayList4.Add("FOR CUSTOMER REVIEW")
MyArrayList4.Add("FOR CUSTOMER APPROVAL")
MyArrayList4.Add("INITIAL RELEASE")
MyArrayList4.Add("ENTER CUSTOM COMMENT")
oArray4 = InputListBox("Select one:", MyArrayList4, "", "iLogic","Choices" )
If oArray4 = "" Then
ElseIf oArray4 = "ENTER CUSTOM COMMENT" Then
oInput4 = UCase(InputBox("What did you change?", "REV","Part#: "& PN &"SN: " & SN))
If oInput4 = "" Then
Else
Dim oCell4 As RevisionTableCell = oRow.Item(4)
oCell4.Text = oInput4
End If
Else
Dim oCell4 As RevisionTableCell = oRow.Item(4)
oCell4.Text = oArray4
End If
']
'[Revision COL 5
Dim MyArrayList5 As New ArrayList
MyArrayList5.Add("AA")
oArray5 = InputListBox("Select one:", MyArrayList5, "", "iLogic", "Checked By ")
If oArray5 = "" Then
Else
Dim oCell5 As RevisionTableCell = oRow.Item(5)
oCell5.Text = oArray5
End If
End Sub
']
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan