Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 516

Use VB.NET dialog in iLogic

$
0
0

By Xiaodong Liang

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.

image

2) In Form_Load, assign the parameters values to the controls. In OK button, update the parameters values with the controls values.

PublicClassMyForm

 

    Public RailHeight AsDouble

    Public Material AsString

    Public Material_List AsArrayList

    Public Comments AsString

    PrivateSub MyForm_Load(sender As System.Object,
              e
As System.EventArgs)
                     
HandlesMyBase.Load

 

        'param which is single value

        TextBox1.Text = CStr(RailHeight)

        'param which is multi-values

        ForEach Material_val
              
AsStringIn Material_List

            ComboBox1.Items.Add(Material_val)

        Next

        ComboBox1.Text = Material

        ' iProperties>>Comments which is multi lines

        TextBox3.Text = Comments

    EndSub

 

    PrivateSub 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()

    EndSub

 

    PrivateSub Cancel_Button_Click(sender As 

                                    System.Object
                       e
As System.EventArgs)
                      
Handles Cancel_Button.Click

        Me.DialogResult =
              System.Windows.Forms.
DialogResult.Cancel

        Me.Close()

    EndSub

EndClass

3) In Inventor file, prepare the corresponding parameters.

 

image

 

image

4) Create a rule as below:

' add the reference of VB.NET dll
AddReference"C:\VBNetFormforiLogic\VBNetFormforiLogic\bin\Debug\VBNetFormforiLogic1.dll"
SubMain()
localTrigger=iTrigger0
' create a form of VB.NET 
UsingdlgAsNewVBNetFormforiLogic.MyForm
' assign the param and property to the form
  dlg.RailHeight=RailHeight
    dlg.Material_List=MultiValue.List("Material")
  dlg.Material=Material  
  dlg.Comments=iProperties.Value("Summary", "Comments")
  'show the dialog
  DimiAsInteger=dlg.ShowDialog()
  'update the param and property from the form
  Ifi<> vbOK ThenReturn
     RailHeight=  dlg.RailHeight
     Material=  dlg.Material
     iProperties.Value("Summary", "Comments")=dlg.Comments
EndUsing
iLogicVb.UpdateWhenDone= True
End Sub

image


Viewing all articles
Browse latest Browse all 516

Trending Articles