So you want to create a kind of QA process for when properties aren't as expected? It's an interesting idea certainly.
I was curious, so I knocked up this rule:
Sub Main()
oDocument = ThisApplication.ActiveDocument
Dim oSheets As Sheets
Dim oPar As UserParameter
For i = 1 To oDocument.Sheets.Count
oDocument.Sheets(i).Activate
oSheet = oDocument.Sheets(i)
Dim oTitleBlock As TitleBlock = oDocument.Sheets(i).TitleBlock
For Each oTextBox As Inventor.TextBox In oTitleBlock.Definition.Sketch.TextBoxes
If oTextBox.Text <> "" Then
CompareTextToExpected(oTextBox, oTitleBlock.GetResultText(oTextBox))
End If
Next
Next
End Sub
Public oDocument As DrawingDocument = Nothing
Public oSheet As Sheet = Nothing
Function CompareTextToExpected(byval textBox as Inventor.TextBox, byval textBoxContents as string) as Boolean
select case textBox.Text
Case "<TITLE>" :
if not textBoxContents = "your expected string" then MarkTextBoxContentsAsIncorrect(textBox, "Text doesn't match expected Title")
case "<PART NUMBER>" :
if not textBoxContents = "your expected string" then MarkTextBoxContentsAsIncorrect(textBox, "Text doesn't match expected Part Number")
end select
End Function
Sub MarkTextBoxContentsAsIncorrect(byval textbox as Inventor.TextBox, byval ErrorText as string)
Call CreateText(textbox.Origin, ErrorText)
End Sub
Sub CreateText (byval textlocation as point2d, byval QAText As String)
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim TextPoint As Point2d = oTG.CreatePoint2d(textLocation.X, textlocation.Y)
Dim oGeneralNotes As GeneralNotes
oGeneralNotes = oSheet.DrawingNotes.GeneralNotes
Dim oGeneralNote As GeneralNote
oGeneralNote = oGeneralNotes.AddFitted(TextPoint, QAText)
End Sub
You can test this just by creating a new blank drawing from the ISO drawing template.
When you run it you get the following output:
![2019-03-08 13_33_46-Autodesk Inventor Professional 2019 - [Drawing1].png 2019-03-08 13_33_46-Autodesk Inventor Professional 2019 - [Drawing1].png](https://forums.autodesk.com/t5/image/serverpage/image-id/611553i21525E3D1E50E44F/image-size/large?v=v2&px=999)
Which proves the code is sound, but the text should be positioned over the title block, whereas the current position matches the position of the textboxes within the titleblock itself:
![2019-03-08 13_35_29-Autodesk Inventor Professional 2019 - [Drawing1].png 2019-03-08 13_35_29-Autodesk Inventor Professional 2019 - [Drawing1].png](https://forums.autodesk.com/t5/image/serverpage/image-id/611555iD0502A13E48B2C55/image-size/large?v=v2&px=999)
I believe I can apply a transformation to a point2d to get the correct location so am investigating that now.
🙂