Closing global form and deleting parameters gives error

Closing global form and deleting parameters gives error

andrewiv
Mentor Mentor
291 Views
2 Replies
Message 1 of 3

Closing global form and deleting parameters gives error

andrewiv
Mentor
Mentor

I have a global form used to configure a part and insert it into an assembly.  This form uses parameters that are created in the assembly as temporary place holders by a rule.  The user runs the rule, the parameters are added, and the form is shown.  The user then changes the parameters on the form and clicks a button to fire another rule to insert the part into the assembly.  Once the part or parts are all inserted there is another button that fires a rule to close the form and delete the place holder parameters.  Everything works fine except for the close rule.  I am always getting this error.

andrewiv_0-1747408052101.png

The error doesn't come up if I don't delete the parameters or if I don't close the form, but I want to do both.  Here is the close rule.

iLogicForm.CloseGlobal("Pulley Configuration")

Dim oAssyDoc As AssemblyDocument = ThisApplication.ActiveEditDocument
Dim oAssyUserParams As UserParameters = oAssyDoc.ComponentDefinition.Parameters.UserParameters
Dim oName As String
Dim oParamNames As New List(Of String)

'Add the required parameter names to the oParamNames list
oParamNames.Add("TEMP_PULLEY_STYLE")
oParamNames.Add("TEMP_PULLEY_TYPE")
oParamNames.Add("TEMP_PULLEY_DIAMETER")
oParamNames.Add("TEMP_FACE_WIDTH")
oParamNames.Add("TEMP_FACE_TYPE")
oParamNames.Add("TEMP_BUSHING_SIZE")
oParamNames.Add("TEMP_LAGGING_TYPE")
oParamNames.Add("TEMP_LAGGING_THICKNESS")

On Error Resume Next

'Delete each parameter in the list
For Each oName In oParamNames
	oAssyUserParams.Item(oName).Delete
Next

Edit: Using Inventor 2024.3.3

Andrew In’t Veld
Designer / CAD Administrator

0 Likes
Accepted solutions (1)
292 Views
2 Replies
Replies (2)
Message 2 of 3

patrick.schlambHPACQ
Participant
Participant
Accepted solution

That is a very interesting problem. I wonder if using the following method to close the form could be a solution, where the button action would close the form rather than the rule itself closing the form. I don't know why that would be the case, but am curious if this would give different results. Credit to @DRoam for the following information. I found this a ways back and have had it saved for various needs. 

  1. Right-click in an empty area of the Global Forms tab, and click Open Containing Folder.
  2. Locate the file with the name of your form (the one WITHOUT .state at the end). Right-click the file, point to "Open With", and click "Notepad".
  3. Hit Ctrl+F and type the name of the External iLogic rule. Click "Find Next" until it highlights a line that says <RuleName> at the beginning.
  4. Directly below this line should be a line that starts with <RuleButtonBehavior> (this is the "Start Tag") and ends with </RuleButtonBehavior> (this is the "End Tag"). Right now it should say "RunRule" between the Start and End Tags.
  5. Erase the the text that's currently between the Start and End Tags, and replace it with the appropriate text for the action you want (see table below).
  6. Save the XML file and close it.
  7. The External iLogic button should now perform the desired "On Click Action".

 

Here are the respective RuleButtonBehavior values for each On Click Action:

          On Click Action               |     RuleButtonBehavior
===================================================================
Run Rule                                |  RunRule
Close and then Run Rule                 |  CloseAndRunRule
Apply and then Run Rule                 |  ApplyValuesAndRunRule
Apply and then Close and then Run Rule  |  ApplyValuesCloseAndRunRule

 

Again, the respective RuleButtonBehavior value should go between the start and end tags in the XML file. So if you want the On Click Action to be "Close and then Run Rule", then the line below <RuleName> in your XML file should look exactly like this:

 

<RuleButtonBehavior>CloseAndRunRule</RuleButtonBehavior>

 

Message 3 of 3

andrewiv
Mentor
Mentor

Yes, that worked.  Thank you for the help!

Andrew In’t Veld
Designer / CAD Administrator