The Form ability of iLogic is helpful in most cases. However, it is not so flexible to design the layout. And textbox does not support multi-lines (iProperties>>Comments cannot be shown) etc.
iLogic bases on VB.NET. Actually it can call native form of VB.NET. Following is the steps of a demo:
1) Create a VB.NET class library project.
Add one form with single-line textbox to communicate with the parameter which is single value; a combo box for a parameter which is multi values; a multi-line textbox for iProperties>>Comments.
2) In Form_Load, assign the parameters values to the controls.
In OK button, update the parameters values with the controls values.
Public Class MyForm
Public RailHeight As Double
Public Material As String
Public Material_List As ArrayList
Public Comments As String
Private Sub MyForm_Load(sender As System.Object, e As System.EventArgs) _
Handles MyBase.Load
'param which is single value
TextBox1.Text = CStr(RailHeight)
'param which is multi-values
For Each Material_val As String In Material_List
ComboBox1.Items.Add(Material_val)
Next
ComboBox1.Text = Material
' iProperties>>Comments which is multi lines
TextBox3.Text = Comments
End Sub
Private Sub OK_Button_Click(sender As System.Object, e As System.EventArgs) _
Handles OK_Button.Click
RailHeight = CDbl(TextBox1.Text)
Material = ComboBox1.Text
Comments = TextBox3.Text
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub Cancel_Button_Click(sender As System.Object, e As System.EventArgs) _
Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
End Class
3) In Inventor file, prepare the corresponding parameters.
4) Create a rule as below:
' add the reference of VB.NET dll. change the absolute path of your own
AddReference "C:\VBNetFormforiLogic\VBNetFormforiLogic\bin\Debug\VBNetFormforiLogic1.dll"
Sub Main()
localTrigger = iTrigger0
' create a form of VB.NET
Using dlg As New VBNetFormforiLogic.MyForm
' assign the param and property to the form
dlg.RailHeight = Parameter("RailHeight")
dlg.Material_List = MultiValue.List("Material")
dlg.Material = Parameter("Material")
dlg.Comments = iProperties.Value("Summary", "Comments")
'show the dialog
Dim i As Integer = dlg.ShowDialog()
'update the param and property from the form
If i <> vbOK Then Return
RailHeight = dlg.RailHeight
Material = dlg.Material
iProperties.Value("Summary", "Comments") = dlg.Comments
End Using
iLogicVb.UpdateWhenDone = True
End Sub
AddReference could also be relative to the path set in Tools Tab>>Advanced iLogic Configuration>>iLogic Addin Dlls Directory. You can put your dll in the directory and use relative path.





Leave a Reply