This can be a bigger job than you might think. Just changing sheet sizes is one thing, and not too difficult. Changing title blocks can be simple or complicated, depending on how you have things set-up and if they contain any prompted entries you need the code to fill in for you. But updating all the different types of styles has the potential for being a much bigger and more complicated task than the other two...again depending on how you have things set-up. To help make this whole styles part of this overall task much easier, I highly recommend than you first create a series of Drawing Standard Styles (DSS) (within your Styles Editor dialog box, they are the top item in the left hand side list, under the heading Standard). One for each sheet size, since all those styles change with the sheet size. Within each of these DSS you can set which ones of all the other types of styles you want it to use, by default, while it is active. Name them similarly to how you named your other style variations. In my code below, I'm expecting that you have created a set of these, and named them according to the following naming scheme: "A0-DDS" (for use with A0 size sheets). If you don't have those DSS set-up yet, and you just want to try out the part of the code where it changes the sheet size and title block, just comment out the last If...Then block of code within the Sub Main portion of the code, then it won't try to run those two other Subs.
Here is some pretty detailed iLogic code you can try out.
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTBDefs As TitleBlockDefinitions = oDDoc.TitleBlockDefinitions
Dim oSheetSizesList As New List(Of String)
oSheetSizesList.AddRange({"A0", "A1", "A2", "A3", "A4" })
Dim oChoice As String = InputListBox("Choose Sheet Size.", oSheetSizesList)
MsgBox("You chose " & oChoice, , "")
Dim oChangedSheetSize As Boolean = False
For Each oSheet As Inventor.Sheet In oDDoc.Sheets
'run the Function defined below to update sheet sizes & title blocks
oChangedSheetSize = UpdateSheet(oSheet, oChoice, oTBDefs)
Next
If oChangedSheetSize Then
'run the Sub defined below to change the active drawing standard style
ChangeStdStyle(oDDoc, oChoice)
'run the Sub defined below to update all existing objects to conform to the new stantard styles
UpdateStylesOfExisting(oDDoc, oChoice)
End If
End Sub
Function UpdateSheet(oSht As Inventor.Sheet, oSize As String, oTBDs As TitleBlockDefinitions) As Boolean
Dim oTargetSheetSize As DrawingSheetSizeEnum
Select Case oSize
Case "A0"
'specify desired sheet size
oTargetSheetSize = DrawingSheetSizeEnum.kA0DrawingSheetSize
Case "A1"
oTargetSheetSize = DrawingSheetSizeEnum.kA1DrawingSheetSize
Case "A2"
oTargetSheetSize = DrawingSheetSizeEnum.kA2DrawingSheetSize
Case "A3"
oTargetSheetSize = DrawingSheetSizeEnum.kA3DrawingSheetSize
Case "A4"
oTargetSheetSize = DrawingSheetSizeEnum.kA4DrawingSheetSize
End Select
If oSht.Size <> oTargetSheetSize Then
oSht.Size = oTargetSheetSize
oChangedSheetSize = True
End If
'now deal with changing the title block
Dim oTBDef As TitleBlockDefinition
Dim oTBDefName As String = oSize & "-TTBL"
Try
oTBDef = oTBDs.Item(oTBDefName)
Catch
MsgBox("Couldn't find a Title Block Definition named '" & oTBDefName & "'.", , "")
Return False
Exit Function
End Try
If oSht.TitleBlock Is Nothing Or _
oSht.TitleBlock.Definition IsNot oTBDef Then
'if there is already a title block on the sheet, this will remove/replace it
oSht.AddTitleBlock(oTBDef)
End If
End Function
Sub ChangeStdStyle(oDrawDoc As DrawingDocument, oSize As String)
Dim oSMgr As DrawingStylesManager = oDrawDoc.StylesManager
Dim oDSStyle As DrawingStandardStyle
'naming scheme for your DrawingStandardStyles within your Styles Manager
'<<<<< THESE DRAWING STANDARD STYLES MUST EXIST FIRST >>>>>>
Dim oDSStyleName As String = oSize & "-DSS"
Try
oDSStyle = oSMgr.StandardStyles.Item(oDSStyleName)
Catch
MsgBox("Couldn't find a DrawingStandardStyle named '" & oDSStyleName & "'.", , "")
Exit Sub
End Try
If oDSStyle IsNot Nothing Then
oSMgr.ActiveStandardStyle = oDSStyle
End If
End Sub
Sub UpdateStylesOfExisting(oDrawDoc As DrawingDocument, oSize As String)
Dim oDSStyle As DrawingStandardStyle = oDrawDoc.StylesManager.ActiveStandardStyle
'just changing the standard won't change these pre-existing objects, it will only effect new objects of these types you create
For Each oSheet As Sheet In oDrawDoc.Sheets
'update dimension styles to comply with new stantard
For Each oGDim As GeneralDimension In oSheet.DrawingDimensions.GeneralDimensions
'assumes the style you use for LinearDimensions is the same style used for all GeneralDimensions
oGDim.Style = oDSStyle.ActiveObjectDefaults.LinearDimensionStyle
Next
For Each oBLDimSet As BaselineDimensionSet In oSheet.DrawingDimensions.BaselineDimensionSets
oBLDimSet.Style = oDSStyle.ActiveObjectDefaults.BaselineDimensionStyle
Next
For Each oChDimSet As ChainDimensionSet In oSheet.DrawingDimensions.ChainDimensionSets
oChDimSet.Style = oDSStyle.ActiveObjectDefaults.ChainDimensionStyle
Next
For Each oOrdDimSet As OrdinateDimensionSet In oSheet.DrawingDimensions.OrdinateDimensionSets
oOrdDimSet.Style = oDSStyle.ActiveObjectDefaults.OrdinateSetDimensionStyle
Next
'update leader styles
For Each oLNote As LeaderNote In oSheet.DrawingNotes.LeaderNotes
oLNote.DimensionStyle = oDSStyle.ActiveObjectDefaults.LeaderTextStyle
Next
'update the view label styles
For Each oView As DrawingView In oSheet.DrawingViews
oView.Label.TextStyle = oDSStyle.ActiveObjectDefaults.ViewLabelStyle
Next
Next
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)