<?xml encoding=”UTF-8″>By Adam Nagy
If you use the same Title Block definition for all Sheet’s then you can go through its Definition, check for the Prompted Entry TextBox’s and keep track of what each TextBox had as value in the main/master sheet where all these values are correct. Now you can update all the other sheets with those values. You could easily modify this code to also update Prompted Entry’s on sheets which are using a different Title Block definition – if they use the same TextBox.Text.
Here is a VBA sample
' "Dictionary" coming from
' "Microsoft Sctipting Runtime" library
' You could simply use an array instead
Function GetPromptedEntries(block As TitleBlock) As Dictionary
Set GetPromptedEntries = New Dictionary
Dim boxes As TextBoxes
Set boxes = block.Definition.Sketch.TextBoxes
Dim box As TextBox
For Each box In boxes
' Check if it's a Prompted Entry
If InStr(1, box.FormattedText, "<Prompt") Then
Dim value As String
value = block.GetResultText(box)
Call GetPromptedEntries.Add(box, value)
End If
Next
End Function
Sub SetPromptedEntries(block As TitleBlock, dict As Dictionary)
If block Is Nothing Then Exit Sub
If dict.Count < 1 Then Exit Sub
Dim firstBox As TextBox
Set firstBox = dict.Keys(0)
Dim blockSketch As DrawingSketch
Set blockSketch = block.Definition.Sketch
' At the moment we only do the update for sheets
' using the same block definition, because we are using
' the TextBox objects as keys, which would be different
' for different title block definitions
If Not firstBox.parent Is blockSketch Then Exit Sub
Dim box As TextBox
Dim value As String
For Each box In dict
value = dict(box)
Call block.SetPromptResultText(box, value)
Next
End Sub
Sub SyncPromptedEntries()
Dim dwg As DrawingDocument
Set dwg = ThisApplication.ActiveDocument
Dim curSheet As Sheet
Dim entries As Dictionary
For Each curSheet In dwg.Sheets
If entries Is Nothing Then
Set entries = GetPromptedEntries( _
curSheet.TitleBlock)
Else
Call SetPromptedEntries( _
curSheet.TitleBlock, _
entries)
End If
Next
End Sub

Leave a Reply