ilogic - get value of prompted entry from sketched symbol

ilogic - get value of prompted entry from sketched symbol

Curtis_Waguespack
Consultant Consultant
1,139 Views
3 Replies
Message 1 of 4

ilogic - get value of prompted entry from sketched symbol

Curtis_Waguespack
Consultant
Consultant

I couldn't find a clear example of getting the value of a prompted entry from a sketched symbol (maybe I overlooked something? ), so here is a simple example in case it helps someone in the future.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oDoc  As Document
oDoc = ThisApplication.ActiveDocument

'find the symbol by name
For Each oSymbol In oDoc.ActiveSheet.SketchedSymbols
	If oSymbol.Name = "RELEASE FOR CONSTRUCTION STAMP" Then 
		'find the text box by name/label
		For Each oTextBox In oSymbol.Definition.Sketch.Textboxes
			If oTextBox.Text = "<RELEASED BY>"
				oString = oSymbol.GetResultText(oTextBox)
				'write value to iproperty
				iProperties.Value("Status", "Eng. Approved By") = oString
				'display value to user
				MessageBox.Show(oString, "iLogic")
			End If
		Next		
	End If
Next

EESignature

Accepted solutions (2)
1,140 Views
3 Replies
Replies (3)
Message 2 of 4

Ethibaudeau
Advocate
Advocate
Accepted solution

Seven years later, the documentation is still vague on this. Thanks for providing the example.
The sketch symbols I am dealing with only have a single text entry so I modified slightly to:

 

 

Dim oTextBox As TextBox
oTextBox = oSketchedSymbol.Definition.Sketch.Textboxes.Item(1)

 

**EDIT: If anyone comes across this, read the next reply in this thread for an improvement.

 

Rather than looping through with a For loop.

 

Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Ethibaudeau.  Just one quick suggestion about that code modification.  When declaring the Type of a variable as TextBox in an iLogic rule or VBA macro, it is best to specify it as Inventor.TextBox, to avoid the potential confusion with the System.Windows.Forms.TextBox Type.  This is a common issue I have seen many times, and it has a very simple solution, as you can see.  Even if you have not used 'AddReference' or 'Imports' statements in your iLogic rules to include that source, that source gets included for us automatically in our rules when certain things (like MessageBox.Show(), and others) are included in our code, and that can lead to potential problems if not planned for.  Any time it is possible for there to be multiple Types with the same name being recognized in your code, adding that little extra specification in there will clear up any possible confusion, and help avoid potential problems.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4

Ethibaudeau
Advocate
Advocate

Thanks for that. Like many people on this forum I think, I have background in some programming, but mostly learning VB for use in Inventor.

0 Likes