INV 2014 - Launch edition of text field of titleblocks

INV 2014 - Launch edition of text field of titleblocks

gmassart
Collaborator Collaborator
357 Views
3 Replies
Message 1 of 4

INV 2014 - Launch edition of text field of titleblocks

gmassart
Collaborator
Collaborator

Hi There

We use Multipages drawings and we need to go through the titleblocks to populate a text field that will be different on each sheets.

Today we need to expand the sheet tree, expand the titleblock tree and then double click on the text field to edit them and this for about 30 sheets !

Is there a way to go through all sheets (basically for each osheet in ...) and launch the titleblock edit form for each pages step by step (think that the API will wait we close the form to continue to go through all sheets)

 

Hope these are clear explanations and thanks in advance for your help.

 

ps : if somebody has a solution to have a table view of all titleblocks (column are text field with prompted text and lines are sheets) it would be a perfect shoot !

Guillaume MASSART
AFFIVAL SAS
Inventor Pro 2022
EESignature

0 Likes
358 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @gmassart.  I have an iLogic rule you can try, but I haven't tested it, because I don't have prompted entries in any of my title blocks.  It may be a little hard to understand right away, so I added several comment lines in the code to help.  This just attempts to handle one promoted entry at a time right now, but loops through each sheet, and each prompted entry found in the title block of each sheet.

 

Dim oDDoc As DrawingDocument = ThisDrawing.Document
'or
'Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
For Each oSheet As Sheet In oDDoc.Sheets
	Dim oTB As TitleBlock = oSheet.TitleBlock
	'get TextBox for the PromptedText we want to change
	Dim oSketch As DrawingSketch = oTB.Definition.Sketch
	Dim oTBox As Inventor.TextBox
	For Each oTBox In oSketch.TextBoxes
		If oTBox.FormattedText.Contains("<Prompt>") Then
			'it contains a placeholder for Prompted Entry/Text
			'get Prompt text (placeholder text, not resulting value), so we know which one it is
			'Split() tries to break the String into an Array of Strings, breaking at specified point
			'need to get text between "<Prompt" and "</Prompt>"
			'Item (1) of that resulting String should be the second half of the String (after that break)
			Dim oPromptName As String = Split(oTBox.FormattedText, "<Prompt")(1)
			'Item (0) here should be the first half of the new resulting String (before the break)
			oPromptName = Split(oPromptName, "</Prompt>")(0)
			
			'get its current value in the title block (result text currently being shown in title block)
			Dim oCurVal As String = oTB.GetResultText(oTBox)
			
			'prompt user to enter new value for it, while showing its current value as default response
			Dim oNewVal As String = InputBox("Prompt Name = " & oPromptName, "Edit Prompted Entry", oCurVal)
			
			'set that new value to the prompted entry in the title block
			oTB.SetPromptResultText(oTBox, oNewVal)
		End If
	Next 'oTBox
Next 'oSheet

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

Hi @gmassart.  I created a test drawing and made a copy of our standard title block (for testing purposes, so I don't mess with the original), and edited it to add a prompted entry to it.  Then saw that my code needed a slight edit, so I quickly edited the original code I posted.  Instead of looking for "<Prompt>", and also using that for the Split routines, I noticed that the text needed to be changed to "<Prompt" (without the immediately following ">", because the first XML tag often has more text after it, while the end tag "</Prompt>" is always in tact.  Just so you know.  I tested the code after making those slight changes, and it worked for me in my test.  However, I'm using Inventor Pro 2021.2.2, instead of Inventor 2014, so I still can't be 100% sure it will work for you.  Good luck.

Here is a link to an online help page for FormattedText and XML tags.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

gmassart
Collaborator
Collaborator

@WCrihfield Thank you but I already manage the "prompt entries" this way to populate date and some other information for the title blocks

My issue was for the specific field of each sheets I need to activate and select each sheet.

I found a workaround creating a form in VBA :

changing sheet with listbox

get the specific field value with

GetResultText

change the value in textboxes and then update the titlebox with

SetPromptResultText

 Work fine this way, need to find a table component similar to Vault view of properties, could be really helpful but I think I will need to develop an AddOn by myself...

Guillaume MASSART
AFFIVAL SAS
Inventor Pro 2022
EESignature

0 Likes