Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JelteDeJong
in reply to: Mathias_CompC

This is how a rule would look like in its most basic form. If this would work for you, would depend on some factors.

In this example, I assumed that there is always a second sheet. Adding a new sheet is not that difficult but it would add more factors to consider. So the rule crashes if you do not have at least 2 sheets.

In this example, I also assumed that your title block does not have any prompted entries. That would also crash the script. fixing that would not be a big deal but would require knowledge of your title block setup.

There are probably some more edge cases that I did not think of. The point is that what you are asking is possible. but would potentially require a lot of tinkering. You might be better off with multiple templates or have a look into sheet format. It will let you add sheets to all the settings that you like.

Dim doc As DrawingDocument = ThisDoc.Document

Dim drawingTypes As New List(Of String)
drawingTypes.Add("Approval")
drawingTypes.Add("Production")

Dim selectedDrawingType = InputListBox("Select Type", drawingTypes, drawingTypes(0))

Dim titleBlockName1 = "Title Block A" ' Default title block for sheet 1
Dim titleBlockName2 = "Title Block B" ' Default title block for sheet1 2
If (selectedDrawingType = drawingTypes(0)) Then
    ' this code is triggerd if the 'Approval' configuration was selected
    titleBlockName1 = "Title Block A"
    titleBlockName2 = "Title Block B"

ElseIf (selectedDrawingType = drawingTypes(1)) Then
    ' this code is triggerd if the 'Production' configuration was selected
    titleBlockName1 = "Title Block C" 
    titleBlockName2 = "Title Block B"
End If

' Setup sheet 1
Dim sheet1 = doc.Sheets.Item(1)
If Not sheet1.TitleBlock Is Nothing Then
    sheet1.TitleBlock.Delete()
End If
sheet1.AddTitleBlock(doc.TitleBlockDefinitions.Item(titleBlockName1))

' Setup sheet 2
Dim sheet2 = doc.Sheets.Item(2)
If Not sheet2.TitleBlock Is Nothing Then
    sheet2.TitleBlock.Delete()
End If
sheet2.AddTitleBlock(doc.TitleBlockDefinitions.Item(titleBlockName1))

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com