Copy title block prompted entries from one sheet to the other

<?xml encoding=”UTF-8″>By Xiaodong Liang

Question:
The title blocks that we use have prompted entries. I would like to find a way using iLogic to copy the entries from one title block to another within the same drawing. 

Solution:
In API, every title block has the corresponding title block definition which defines the prompt text. When the end user tries to insert a title block, the mechanism behind is inserting an instance of the title block definition. The user will be asked to input the final text for the prompt text.  the API object TitleBlock provides the method GetResultText to know the final text. Conversely, if you want to set the final text, you can call TitleBlock.SetPromptResultText.

Following iLogic code assumes the drawing has two sheets which use the same title block. In the title block, there is one prompt text named “MY_PROMPT”. It will get the result string in sheet1 and copies to sheet2.

 ' assume sheet1 and sheet use the same title block definition
Dim oDoc
oDoc = ThisApplication.ActiveDocument
'get first sheet
Dim oSheet1
oSheet1 = oDoc.Sheets(1)
'get titleblock of sheet1
Dim oTB1
oTB1 = oSheet1.TitleBlock
' search the textbox in definition
Dim oPromptText
Dim oEachText
Dim I
For I = 1 To oTB1.Definition.Sketch.TextBoxes.Count
oEachText = oTB1.Definition.Sketch.TextBoxes(I)
If (oEachText.Text = "MY_PROMPT") Then
' found the prompt text we want to copy
oPromptText = oEachText
Exit For
End If
Next I
'get the result string of the prompt text
Dim oPromptEntry
oPromptEntry = oTB1.GetResultText(oPromptText)
'get sheet2
Dim oSheet2 As Sheet
oSheet2 = oDoc.Sheets(2)
'get titleblock of sheet2
Dim oTB2 As TitleBlock
oTB2 = oSheet2.TitleBlock
' copy the result string of the prompt text to the prompt text in sheet2
oTB2.SetPromptResultText(oEachText, oPromptEntry)

Comments

3 responses to “Copy title block prompted entries from one sheet to the other”

  1. Hello, this code is awsome, but I need the oposite thing, what code do I need to enter information when I create a new sheet without using promtedentrys in any text box from the title block…also assuming alls sheets use the same title block??
    Thanks.

  2. VPMAIL321@GMAIL.COM Avatar
    VPMAIL321@GMAIL.COM

    PLEASE PUT HOW TO ADD MORE ENTRIES

  3. VPMAIL321@GMAIL.COM Avatar
    VPMAIL321@GMAIL.COM

    PLEASE EXPLAIN WHAT TO DO FOR MORE NUMBER OF ENTRIES.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading