Is it possible using ilogic & prompted entry to fill in an inputbox and have the information show up on the idw.

Is it possible using ilogic & prompted entry to fill in an inputbox and have the information show up on the idw.

SHUREBJE
Participant Participant
1,142 Views
9 Replies
Message 1 of 10

Is it possible using ilogic & prompted entry to fill in an inputbox and have the information show up on the idw.

SHUREBJE
Participant
Participant

We use title box's in our idw files to print & send to our production. In these files are (3) prompted entry's

called QTY:, CUSTOMER INFO: & CUST. ORDER#:>.

I would like to be able to have maybe an inputbox that would ask you to fill out the (3) entry's allowing the information to show up on the printed file.

The end result would be to be able to print multiple drawings from an assembly, and then have the entry's be filled out in all the drawings. I have a program to print the drawings from assembly's, I'm just not sure how to fill in the entry's.

Any help or links to other forums is appreciated.

0 Likes
Accepted solutions (1)
1,143 Views
9 Replies
Replies (9)
Message 2 of 10

Andrii_Humeniuk
Advisor
Advisor

Hi @SHUREBJE . If you need to add parameters to your components, then it's best to use a function the "Bill of material":
1. Open the "Bill of Material"; 2. Click "Add Custom iProperty Colomns"; 3. Add your iProperty.

 

Screenshot 2023-05-01 200343.png

If to the main assembly or to your drawings, then describe any detail where you need to add your parameters.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 10

WCrihfield
Mentor
Mentor
Accepted solution

Hi @SHUREBJE.  Here is an example iLogic rule you can use on a drawing that has some 'prompted entries' in its title block.  This version can be used to process every sheet of the drawing that might contain a title block that may contain any promted entries, and will prompt you for each prompted entry.  In the InputBox it will provide prompted entry's prompt text as the prompt text of the InputBox, then it will also include the prompted entry's current value as the default value for you.

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule only works on drawings.", vbCritical, "Wrong Document Type")
	Exit Sub
End If
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

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 10

SHUREBJE
Participant
Participant

Thank you for the help I will look into this.

0 Likes
Message 5 of 10

SHUREBJE
Participant
Participant

Thank you this is exactly what I was looking for.

0 Likes
Message 6 of 10

drafting4KGWTN
Contributor
Contributor

hey mate,

 

I'm not well-versed enough in ilogic to work it out yet so I'll ask.

is there any way that coding can be utilised to only work on the active sheet?

0 Likes
Message 7 of 10

WCrihfield
Mentor
Mentor

Sure, @drafting4KGWTN.  Here is a slightly modified version of that code, designed to only focus on the active sheet of the current drawing.

 

Sub Main
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then Return
	Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
	If oSheet.TitleBlock Is Nothing Then Return
	Dim oTBlock As TitleBlock = oSheet.TitleBlock
	Dim oSketch As DrawingSketch = oTBlock.Definition.Sketch
	Dim oTBoxes As Inventor.TextBoxes = oSketch.TextBoxes
	Dim sP1 As String = "<Prompt>" : Dim sP2 As String = "</Prompt>"
	For Each oTBox As Inventor.TextBox In oTBoxes
		If Not oTBox.FormattedText.Contains("</Prompt>") Then Continue For
		Dim sPrompt As String = oTBox.Text.Trim("<", ">")
		Dim sPromptResult As String = oTBlock.GetResultText(oTBox)
		Dim sNewValue As String = InputBox(sPrompt, "Prompted Entry", sPromptResult)
		oTBlock.SetPromptResultText(oTBox, sNewValue)
	Next
End Sub

 

You might also like to review a newer discussion in this same area at the following link.  In that conversation I also provided some useful text file attachments containing iLogic code resources that may come in handy later on, if/when your needs in this area get a little more complex.

https://forums.autodesk.com/t5/inventor-programming-ilogic/setting-prompted-entries-text-after-title... 

 

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 8 of 10

drafting4KGWTN
Contributor
Contributor

thanks legend! Works a dream

0 Likes
Message 9 of 10

drafting4KGWTN
Contributor
Contributor

hey @WCrihfield

thanks for the link, though i cant really get the attached codes to work.

I'm now trying to go a little further on the code you already tweaked for me.
I've got several separate prompted entries on my title block, is there any way the code can be worked to call out specific prompted entries?

 

Example for context in the attached screenshot. I may need to only use the highlighted row(s) and not the ones above. Currently if i want to edit those prompted entries, running the provided code will cycle through all of them each time i want to make an edit to a specific row. I'd like to be able to have a code where it'll access the desired row/entries only. (if i need to have a separate code for each of the rows above the 1st that's no issue)

tdTaXcMj8U.jpg

For the last couple of weeks I've tried poaching snippets on these forums but to no avail.


 

0 Likes
Message 10 of 10

WCrihfield
Mentor
Mentor

Hi @drafting4KGWTN.  Is that a true Inventor.RevisionTable type object in the image, or is it custom geometry that was created within the sketch of the TitleBlockDefinition, with individual TextBoxes placed within its geometry for the needed data?  If it is custom geometry with a bunch of individual TextBoxes added in, then the primary challenge here would be to determine which specific TextBox object is for which specific piece of data.  Is every piece of text in that image a prompted entry?  If so, then when you attempt to manually fill in their values right now, what do the prompts in that dialog look like?...and how can you tell which ones are which within that dialog?  The names of the prompts may be different than what is actually showing in that image, and if so, we may need to know those prompt names, and may need to list them within the code somewhere if we will be checking for them.  We may need to create something like a Dictionary(Of String, String) or NameValueMap within the code, so that we can fill in all the prompt names, paired with the values that we want to set for them.  Then as the code iterates through them, it can check each one against the specified prompt names to find just the ones you are interested in, and when that happens, fill in its value with the value specified for that prompt name in the Dictionary or NameValueMap.

 

Since TextBox objects do not have 'names', we must rely on the values of a few of its properties to help us identify them.  When the TextBox is not for a prompted entry, and does not contain any 'Linked' type value, then the TextBox.Text property's value will simply contain the exact contents of the TextBox.  But when it is for a prompted entry, or 'Linked' data, then the TextBox.Text property's value may be what you see in the Format Text dialog box, instead of the actual data that may be showing within that TextBox when not editing its definition.  So, in those cases, we must either be familiar with what that looks like in the Format Text dialog, or be familiar with what the FormattedText will contain (also usually not what you will see in the TextBox when not editing its definition).  In the most basic and simple scenarios, like when the TextBox only contains simple typed in text, with no special formatting, no prompted entry, and no 'Linked' data, then both the TextBox.Text property and the TextBox.FormattedText properties will both contain the same contents, which will just be that typed in text...but that is the only situation when that will be the case.

 

I mentioned that the TextBox object does not have a 'Name' type property, but there is actually another way that we can assign a name or unique identifier to each of them, with some extra preparation effort and with come additional code based help.  This can be done starting from the TextBox.AttributeSets property.  That AttributeSets collection object that you get from that property will normally not contain any actual AttributeSet objects at first, so we would have to create one using its AttributeSets.Add method, which asks us to assign it a name when we create it.  But that is not where we will assign the name for this TextBox, just a name for the collection of similar assigned names (like "Revision Table Prompted Entries Set").  Then, we can use the AttributeSet.Add method to create an actual Attribute object in it.  This is where we can set a name for the Attribute object itself (such as "Revision Table Prompted Entry"), and set its value type (ValueTypeEnum.kStringType), and finally set the name for the TextBox object as the value of this Attribute (such as "Rev #" or "Date #" or "Designer #", where # is replaced by row number, or something like that, to differentiate the one in one row from the same one in another row.

There is simply a lot to this sort of thing, and it is all very highly custom to just you, and that one TitleBlockDefinition's Sketch.

Maybe attaching one of your drawing files would help (not in a Zip file, because I can not download those), but I can not guarantee that I will be able to spend much time working on it, because I have a lot of my own stuff to get done where I work.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes