'Read Title Block from Active Sheet
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oTB1 As TitleBlock
oTB1 = oSheet.TitleBlock
Dim titleDef As TitleBlockDefinition
titleDef = oTB1.Definition
Dim oPrompt As TextBox
' Find the Prompted Entry called <MATERIALS> in the Title Block
For Each defText As TextBox In titleDef.Sketch.TextBoxes
If defText.Text = "<MATERIALS>" Then
oPrompt = defText
ElseIf defText.Text = "<Bemaning 1>" Then
oPrompt2 = defText
ElseIf defText.Text = "<BENAMING 1>" Then
oPrompt3 = defText
ElseIf defText.Text = "<BENAMING 2>" Then
oPrompt4 = defText
ElseIf defText.Text = "<Eenheden>" Then
oPrompt5 = defText
ElseIf defText.Text = "<DATUM>" Then
oPrompt6 = defText
ElseIf defText.Text = "<Tolerantie>" Then
oPrompt7 = defText
ElseIf defText.Text = "<MATERIAL>" Then
oPrompt8 = defText
ElseIf defText.Text = "<Klant>" Then
oPrompt9 = defText
ElseIf defText.Text = "<Referentie>" Then
oPrompt10 = defText
' Exit For <- You need to remove this line as it is exiting the loop once it finds the variable you are looking for
'Else Return
End If
Next
'write prompted entry to iprop
Dim Mat As String
Dim Mat2 As String
Dim Desc1 As String
Dim Desc1a As String
Dim Desc2 As String
Dim Units As String
Dim oDatum As String
Dim Tol As String
Dim klant As String
Dim oReference As String
Mat = oTB1.GetResultText(oPrompt)
iProperties.Value("Custom", "TMP_MATERIALS") = Mat
Desc1 = oTB1.GetResultText(oPrompt2)
iProperties.Value("Custom", "TMP_Bemaning 1") = Desc1
Desc1a = oTB1.GetResultText(oPrompt3)
iProperties.Value("Custom", "TMP_BENAMING 1") = Desc1a
Desc1a = oTB1.GetResultText(oPrompt4)
iProperties.Value("Custom", "TMP_BENAMING 2") = Desc1a
Units = oTB1.GetResultText(oPrompt5)
iProperties.Value("Custom", "TMP_Eenheden") = Units
oDatum = oTB1.GetResultText(oPrompt6)
iProperties.Value("Custom", "TMP_DATUM") = oDatum
Tol = oTB1.GetResultText(oPrompt7)
iProperties.Value("Custom", "TMP_Tolerantie") = Tol
Mat2 = oTB1.GetResultText(oPrompt8)
iProperties.Value("Custom", "TMP_MATERIAL") = Mat2
klant = oTB1.GetResultText(oPrompt9)
iProperties.Value("Custom", "TMP_Klant") = klant
oReference = oTB1.GetResultText(oPrompt10)
iProperties.Value("Custom", "TMP_Referentie") = oReference
********ERROR MESSAGE*********************
'System.ArgumentException: De Parameter Is onjuist. (Exception From HRESULT: 0x80070057 (E_INVALIDARG))
' at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
' at Inventor.TitleBlock.GetResultText(TextBox DefinitionText)
' at ThisRule.Main()
' at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
' at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
This is where I am at right now. I feel that I am close to the result I am looking for, however there is an error message when I run the rule. I looked it up, and it might have something to do with "Normal" tekst boxes mixed with "Prompted" ones. I have tried some solutions but all I seem to be doing it making things worse.
The error message is: 'Exception from HRESULT: 0x80070057 (E_INVALIDARG)'
I want to use this rule for different drawing with different titleblocks, so it might not find all the field I am searching for. But I donkt think that is the issue.
Any clue of what I am doing wrong? As always, any kind of help is greatly apprciated!