Creating temporary User Parameters in a drawing for a multi-selection iLogic form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to build a drawing note based on user selected options in iLogic. I am using Inventor Pro 2020 (moving to 2022 soon).
Instead of asking a series of Yes/No questions (whether to include something in the note or not), I would like the put up a dialog with checkboxes so the user can go down the list in ONE dialog and select the items to include.
To achieve this, I thought that I would create temporary “storage” by using either iProperties or Parameters in the drawing, one Boolean for each option that I want to include in my note (iLogic form entities must be based on either a Parameter, Rule or iProperty, nothing else allowed that I can see). By using Boolean iProperties or Parameters, I was looking to create an iLogic form with checkboxes to easily tick off what notes that are wanted. Afterward, I append the desired notes together based on the responses and then clean up my mess by deleting the temporary things I created.
I am successful at creating and deleting both User Parameters and Custom iProps in either a drawing or model file using iLogic.
First issue: I found that iLogic forms do NOT allow me to display Boolean Custom iProps with checkboxes on the form (only dropdown boxes – less convenient for my purposes because 2 clicks are required for a selection rather than just 1). Therefore, I eliminated using iProps as my vehicle.
This quickly brings me to my second issue: I can’t add Boolean User parameters in a drawing file to an iLogic form (they simply do not appear on the list).
As a workaround, I created an IPT with the User Parameter names I wanted and then created a Global iLogic form from the IPT. When running my routine on a drawing, I get the form to display but when I click a checkbox I get an warning dialog box (attached) every time I click something. Despite the error, I get the parameters to change as desired. I have included an image of my form and a Message confirming what I selected.
As a test, I commented out my deletion of the parameters at the end of my routine so they are left defined. I then brought up the Parameters dialog for the drawing interactively. When I change the state of my iLogic created parameters, I get the same error as when running my routine. Thus, it appears that my problem may be with my UserParameters declaration where I define “oUP” in my code).
I am attaching my testing routine. Anyone know what I'm doing wrong?
Const Ext As Integer = 5
Dim oUP As UserParameters
'Following works for model files
'oUP = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
'Following seems to work for drawings but throws an error when I change the User Parameter
oUP = ThisApplication.ActiveDocument.Parameters.UserParameters
Dim oTest As Parameter
Dim ErrFlg As Boolean = False
Dim i As Integer
'Test for the pre-existance of the user parameters and create if missing
For i = 0 To Ext
On Error Resume Next
oTest = oUP.Item("Question" & i)
If Err.Number <> 0 Then
'create parameter
oUP.AddByValue("Question" & i, False, kBooleanUnits)
Else
ErrFlg = True
Exit For
End If
Next i
On Error GoTo 0
If ErrFlg Then
MessageBox.Show("Pre-existing User Parameter Conflict", "ERROR",MessageBoxButtons.OK,MessageBoxIcon.Stop)
Exit Sub
End If
iLogicForm.ShowGlobal("Select Notes", FormMode.Modal)
'Display my responses
Dim q(0 To Ext) As String
Dim mess As String = "Results:"
For i = 0 To Ext
If oUP.Item("Question" & i).Value Then
q(i) = "Yes"
Else
q(i) = "No"
End If
mess = mess & vbCrLf & "Question" & i & ": " & q(i)
Next i
MessageBox.Show(mess, "Responses")
' Cleanup
For i = 0 To Ext
oUP.Item("Question" & i).Delete
Next i