11-26-2024
06:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-26-2024
06:35 PM
I've been doing some digging today and found some code that does what i want. The only problem is, it loops through the prompt entries to each sheet in the IDW set.
after trial and error, i managed to alter the code so the loop stops after one sheet. But it'll only change the prompts on the 1st sheet - as opposed to the one that is active
please see below for both pieces of code
(code looping through each sheet)
Dim oDDoc As DrawingDocument = ThisDoc.Document Dim oSheets As Inventor.Sheets = oDDoc.Sheets For Each oSheet As Sheet In oSheets If oSheet.TitleBlock Is Nothing Then Continue For Dim oTB As TitleBlock = oSheet.TitleBlock Dim oSketch As DrawingSketch = oTB.Definition.Sketch Dim oTBoxes As Inventor.TextBoxes = oSketch.TextBoxes If oTBoxes.Count = 0 Then Continue For Dim sP1 As String = "<Prompt>" : Dim sP2 As String = "</Prompt>" For Each oTBox As Inventor.TextBox In oTBoxes If Not oTBox.FormattedText.Contains(sP2) Then Continue For Dim sPrompt As String = oTBox.Text.Substring(1, oTBox.Text.Length - 2) Dim sCurVal As String = oTB.GetResultText(oTBox) Dim sNewVal As String = InputBox(sPrompt, "Prompted Entry", sCurVal) oTB.SetPromptResultText(oTBox, sNewVal) Next 'oTBox Next 'oSheet
code terminating after 1st cycle (but only writing to 1st sheet)
Dim oDDoc As DrawingDocument = ThisDoc.Document Dim oSheets As Inventor.Sheets = oDDoc.Sheets For Each oSheet As Sheet In oSheets If oSheet.TitleBlock Is Nothing Then Continue For Dim oTB As TitleBlock = oSheet.TitleBlock Dim oSketch As DrawingSketch = oTB.Definition.Sketch Dim oTBoxes As Inventor.TextBoxes = oSketch.TextBoxes If oTBoxes.Count = 0 Then Continue For Dim sP1 As String = "<Prompt>" : Dim sP2 As String = "</Prompt>" For Each oTBox As Inventor.TextBox In oTBoxes If Not oTBox.FormattedText.Contains(sP2) Then Continue For Dim sPrompt As String = oTBox.Text.Substring(1, oTBox.Text.Length - 2) Dim sCurVal As String = oTB.GetResultText(oTBox) Dim sNewVal As String = InputBox(sPrompt, "Prompted Entry", sCurVal) oTB.SetPromptResultText(oTBox, sNewVal) Next 'oTBox If oSheet IsNot oActiveSheet Then Exit Sub End If Next 'oSheet