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