Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
1. I have a TitleBlock in my Drawing Document with multiple TextBoxes, i filled these TextBoxes with strings so I can Identify what textbox i'm working with and change the Text of them with a specific variable from (2).
2. I have a big list of variables: 1 to n
What i want to do is fill the TextBox with a specific variable, but i have problems doing this:
- I managed to Identify a TextBox, but i am unable to change the text
- Since the number of TextBoxes and the number of Variables is quite big, i prefer not to make very long if-else statement. If it's possible to do this with two collections/arrays (one for the textboxes and one for the vairables) and nest them somehow it would be perfect. But my programming knowledge on how to do this is limited
Here is my code with some comments
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.Sheets(1)
oSheet.Activate
Dim Var1, Var2 As String 'variables 1 to n
Var1 = "xxxx"
Var2 = "yyyy"
Dim oTitleBlock As TitleBlock = oSheet.TitleBlock
Dim oTitleBlockDefinition As TitleBlockDefinition = oTitleBlock.Definition
Dim oSketch As DrawingSketch
Dim oTB As Inventor.TextBox 'textboxes 1 to n
oTitleBlockDefinition.Edit(oSketch)
For Each oTB In oSketch.TextBoxes
oTBT = oTB.Text
If oTBT = "Var1" Then
oTBT = Var1 'THE CONDITION WORKS FINE BUT THIS LINE DOESN'T ACTUALLY CHANGE THE TEXT
Else If oTBT = "Var2" Then
oTBT = Var2 'THE CONDITION WORKS FINE BUT THIS LINE DOESN'T ACTUALLY CHANGE THE TEXT
'n
End If
Next
oTitleBlockDefinition.ExitEdit()
Basically if the Text from the TextBox in my Titleblock equals "Var1" i want to change it's text to the actual Var1 variable.
Solved! Go to Solution.