iLogic Prompted Entry/Field Text to Custom iProperties

iLogic Prompted Entry/Field Text to Custom iProperties

creggo
Enthusiast Enthusiast
1,175 Views
5 Replies
Message 1 of 6

iLogic Prompted Entry/Field Text to Custom iProperties

creggo
Enthusiast
Enthusiast

Hi Folks,

 

Trying to extract prompted entry/field text from an old border to custom iproperties. Using the code from this thread:

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-rule-to-get-a-propmted-text-v...

 

Works very well, I've got most the data extracted already, however I'm having trouble getting the revision table information, as the field text names are not unique. I'd like each occurrence of the following entries to be written to a unique custom iProperty. For example, first occurrence of "ISSUE" -> iProperties.Value("Custom", "ISSUE_01") etc. Right now it will get the revision 10 line information, I guess that's the first instance of the defText it can find.


Any help would be much appreciated!

'Read Field Text from Border in Active Sheet

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oBD1 As Border
oBD1 = oSheet.Border
Dim BorderDef As BorderDefinition
BorderDef = oBD1.Definition
Dim oPrompt1 As TextBox
Dim oPrompt2 As TextBox
Dim oPrompt3 As TextBox
Dim oPrompt4 As TextBox
Dim oPrompt5 As TextBox
Dim oPrompt6 As TextBox
Dim oPrompt7 As TextBox
Dim oPrompt8 As TextBox
'make sure you declare all your prompts


' Find the Prompted Entry in the Border
For Each defText As TextBox In BorderDef.Sketch.TextBoxes
	On Error Resume Next	
	If defText.Text = "ISSUE" Then
		oPrompt1 = defText
	ElseIf defText.Text = "DRF No." Then
		oPrompt2 = defText
	ElseIf defText.Text = "MODIFICATION" Then
		oPrompt3 = defText
	ElseIf defText.Text = "DRAWN BY" Then
		oPrompt4 = defText
	ElseIf defText.Text = "DATE" Then
		oPrompt5 = defText
	ElseIf defText.Text = "CHKD" Then
		oPrompt6 = defText
	ElseIf defText.Text = "APPROVED BY" Then
		oPrompt7 = defText
	ElseIf defText.Text = "MFG APP BY" Then
		oPrompt8 = defText
	End If
Next

'write prompted entry to iprop
Dim T1 As String
Dim T2 As String
Dim T3 As String
Dim T4 As String
Dim T5 As String
Dim T6 As String
Dim T7 As String
Dim T8 As String
'Declare all your unique strings

T1 = oBD1.GetResultText(oPrompt1)
T2 = oBD1.GetResultText(oPrompt2)
T3 = oBD1.GetResultText(oPrompt3)
T4 = oBD1.GetResultText(oPrompt4)
T5 = oBD1.GetResultText(oPrompt5)
T6 = oBD1.GetResultText(oPrompt6)
T7 = oBD1.GetResultText(oPrompt7)
T8 = oBD1.GetResultText(oPrompt8)
'set all unique strings to unique prompts

iProperties.Value("Custom", "ISSUE") = T1
iProperties.Value("Custom", "DRF No.") = T2
iProperties.Value("Custom", "MODIFICATION") = T3
iProperties.Value("Custom", "DRAWN BY") = T4
iProperties.Value("Custom", "DATE") = T5
iProperties.Value("Custom", "CHKD") = T6
iProperties.Value("Custom", "APPROVED BY") = T7
iProperties.Value("Custom", "MFG APP BY") = T8
'Set all iProperties To unique strings

 

0 Likes
Accepted solutions (1)
1,176 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

Any Chance of showing images of what attributes your searching for and where there located. I don't have Inv 2023. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

JelteDeJong
Mentor
Mentor
Accepted solution

You could try something like this:

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim borderDef As BorderDefinition = sheet.Border.Definition

Dim reg As New Text.RegularExpressions.Regex("<Prompt ReadOnlyUniqueID='(\d+)'>([\s\S]+)<\/Prompt>")

For Each tb As Inventor.TextBox In borderDef.Sketch.TextBoxes
	If (Not tb.FormattedText.Contains("<Prompt")) Then Continue For

	Dim match = reg.Match(tb.FormattedText)

	Dim Name = String.Format("{1} ({0})", match.Groups.Item(1), match.Groups.Item(2))
	Dim result = sheet.Border.GetResultText(tb)

	iProperties.Value("Custom", Name) = result
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 6

creggo
Enthusiast
Enthusiast

Hi @A.Acheson, the border definition properties, you can see the rev table area names are all the same. 
Creggo_0-1666595188590.png

Creggo_1-1666595242034.png

 

0 Likes
Message 5 of 6

creggo
Enthusiast
Enthusiast

Thank you @JelteDeJong! This works very well, all prompts are now iproperties, exactly what I was looking for.

Creggo_0-1666596156218.png

Cheers,

Craig

 

0 Likes
Message 6 of 6

creggo
Enthusiast
Enthusiast

Out of curiosity, could this same method be used to extract standard iProperties out the border definition as well?

Creggo_0-1666614392654.png

 

I can use the ilogic in the original post to do this, adding each property manually, but would be useful to get all <Standard iProperties> similar how @JelteDeJong managed with prompted entries.

 

Thanks

0 Likes