Cannot Pull Prompted Entry with VBA

Cannot Pull Prompted Entry with VBA

MichaelTV334
Explorer Explorer
332 Views
2 Replies
Message 1 of 3

Cannot Pull Prompted Entry with VBA

MichaelTV334
Explorer
Explorer

Visual Studio 2019. Inventor 2022. 

I'm trying to pull <TITLE> from a titleblock. Some of my titleblocks are prompted entry, and others pull from a part. In either case, I see <TITLE> when looking at the titleblock.

I cannot get my code to read the prompted entry field, but if a sheet doesn't use a prompted entry for <TITLE> then it will read the value. 

When I have the values input into excel, the prompted entry values are blank, but the auto-read values appear.

Here is the portion of my code that reads the value.

 

For Each otextbox In colTextBoxes

   If otextbox.Text = "<TITLE>" Or otextbox.Text = "PROJECT_TITLE" Then
      oDrawingTitle = otextbox
      Continue For
   End If

Next

 

If I put in a 

Or otextbox.Text = "TITLE" Then

after the other conditions.

When I do this without the <> before TITLE and the blank values in excel become TITLE .

Does anyone have an idea of how to read prompted entry values?

0 Likes
333 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

From reading and testing the post from here

The below sample should work. 

 

Public Sub TitleBlock()
	
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument

    Dim oTitle As Inventor.TitleBlock
    Set oTitle = oDoc.ActiveSheet.TitleBlock

    Dim oTextBox As TextBox

    Dim oTextBoxes As TextBoxes

    Dim sData As String

    Set oTextBoxes = oTitle.Definition.Sketch.TextBoxes

    For Each oTextBox In oTextBoxes

      sData = oTitle.GetResultText(oTextBox)

      If oTextBox.text = "COMPANY" Then

      	Company = sData

      	MsgBox (Company)

      End If

    Next

End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

Handling prompted entries by code can get complicated.  How complicated and which route to take depends a lot on how you set everything up.  Here are a few more links you might want to check out.

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/grab-view-title-place-it-into-a-prompte... 

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/copy-prompted-entries-to-drawing-custom... 

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/editing-prompted-entry-values-with-ilog... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes