Read Prompted Entry through code

By Barbara Han

Issue

I need to get the property fields which can be seen in "Edit property text" under active Title block. I am able to get other property fields related to drawing through property set, but I don’t how to get the custom property set (Prompted Entry) for Title block.

Solution

The following is a VBA sample code that reads the prompted entry in the title block in the active sheet:

‘Before running this code, add reference to Microsoft XML 6.0 in this VBA project

Sub readPromptedEntryInTitleBlock()
    Dim drawing As DrawingDocument
    Set drawing = ThisApplication.ActiveDocument
    Dim tb As TitleBlock
    Set tb = drawing.ActiveSheet.TitleBlock
    Dim textB As TextBox
    For Each textB In tb.Definition.Sketch.TextBoxes
        Dim xml As DOMDocument
        Set xml = New DOMDocument
        Call xml.loadXML(textB.FormattedText)
       
        ‘ Look for prompted entry
        Dim node As IXMLDOMNode
        Set node = xml.selectSingleNode("Prompt")
        If Not node Is Nothing Then
            Debug.Print node.Text + ":" + tb.GetResultText(textB)
        End If
       
        Set xml = Nothing
    Next
End Sub
 
Actually there is no need to look for the properties from property set, because it’s straight forward to get all texts in the title block through calling TitleBlock.GetResultText() function.

There are some discussion threads talking about the similar issue, for example:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Reading-quot-Prompted-Entry-quot-Title-Block-info-with-VBA/td-p/758297


Comments

One response to “Read Prompted Entry through code”

  1. Davide Brizio Avatar
    Davide Brizio

    With .NET is even easier because you can edit the sketch and loop through all the textboxes looking for the “PROMT” entries in the .FormattedText property.
    But I have another question: how can you read the VALUE of a prompted text in a title block?
    I need to change a title block with another, keeping the values of the prompted entries, can you suggest a method please?
    Thanks
    Davide

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading