Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good morning,
Working through some program stuff that allows the users to select the correct title block from a form. During this it removes the names of the sheets themselves. So I am attempting to re-establish those names according to the name of the sheets in the model browser.
In doing so I think I'm tackling the problem in the wrong direction, either leading me to an index to array size mismatch or a unspecified error.
The question is, are you unable to modify the sketch.textbox text after the prompted entries have been passed into the title block creation? See code for more information (Code erroring out at line 23 of block 1).
Call SelectTitleBlock(TitleBlockDef)
Call CollectedTitleEntries(TitleBlockDef, PromptStrings)
Call CheckAndRemoveTitleblocks()
For Each osheet1 As Sheet In oDoc.Sheets
Dim Titleblock As TitleBlock = osheet1.AddTitleBlock(TitleBlockDef, , PromptStrings)
Next
Dim PageNameStrings(3) As String
PageNameStrings(0) = oPage1.Name
PageNameStrings(1) = oPage2.Name
PageNameStrings(2) = oPage3.Name
PageNameStrings(3) = oPage4.Name
Dim TextIndex As Integer = 0
For Each osheet1 As Sheet In oDoc.Sheets
For Each oTB As Inventor.TextBox In TitleBlockDef.Sketch.Textboxes
If oTB.Text.Contains("<SHEET NAME>") = True Then
oTB.Text = "Hello world" 'PageNameStrings(TextIndex)<-- This will error depending on location of the text index increase. Two locations = unspecified error, one location = array to index size mismatch.
TextIndex = TextIndex + 1
End If
Next
Next
Sub CollectedTitleEntries(ByVal TitleBlockDef As TitleBlockDefinition, ByRef PromptStrings() As String)
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oPage1 As Sheet = oDrawDoc.Sheets.Item(1)
'Dim TitleBlockDef As TitleBlockDefinition = oDrawDoc.TitleBlockDefinitions.Add(TitleSelection) 'Title selection will need to be a sub that passes the selected title block definition string name into this sub for collecting prompted entires.
Dim PromptedTitleFields As New List(Of String) 'This establishes an array of strings
For Each oTB As Inventor.TextBox In TitleBlockDef.Sketch.TextBoxes 'Searching through each text box on the nozzelfittingsketchdefinition
If oTB.Text.Contains("<") AndAlso oTB.Text.Contains(">") Then 'As it searches it finds any text within a box to contain both these items it adds it to the collection ------->'If oTB.Text.Contains("<SHEET NAME>") Then
PromptedTitleFields.Add(oTB.Text)
End If
Next
'This section below is establishing the uservalue of an inputbox to the prompted strings of the above sketched object. This is required for any sketched symbol with a prompted text need.
'Dim PromptStrings(PromptedTitleFields.Count - 1) As String
ReDim PromptStrings(PromptedTitleFields.Count - 1)
For iIndex1 = 0 To PromptedTitleFields.Count - 1
PromptStrings(iIndex1) = PromptedTitleFields(iIndex1)
Logger.Info(PromptStrings(iIndex1) & " At the index: " & iIndex1)
Next
End Sub
Solved! Go to Solution.