iLogic gui or form for user input

iLogic gui or form for user input

Guido.LangeTuchscherer
Enthusiast Enthusiast
5,137 Views
6 Replies
Message 1 of 7

iLogic gui or form for user input

Guido.LangeTuchscherer
Enthusiast
Enthusiast

Hello there,

 

I am fairly new to ilogic, I managed to automatically get assembly and component sizes into costum iProperties and know how to read an excel sheet and get the information I want from it.

 

Now I need a user input to then afterwards write the information into the iProperties.

 

Getting the user input is the question here:

I could use several inputlistbox after each other, but this would be inconvinient.

I would prefer some kind of gui like the one below (see image), without using multivaluelist.

Thinking of a top-down functionality, depending on the choices the lower fields have to update.

Similar but not the same as the content center menue.

 

Is it even possible in iLogic or do I have to dal with VBA?

And if so is there a good tutorial somewhere?

 

Ok I found this earlies post where some links and input is given:

https://forums.autodesk.com/t5/inventor-customization/inventor-vba-userform-documentation-or-tutoria...

but the question remains if this is the only way?

 

Grundmaterialauswahl.png

0 Likes
Accepted solutions (2)
5,138 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

You could also use an iLogic form (different than a VBA userform).

You can more quickly and easily create a simple iLogic form, than a VBA userform.

However, depending on how complex you want your finished form to be, a VBA userform can have more options and design flexibility (and therefore also more complex).

You can't really manipulate the design or functionality of an iLogic form from an iLogic rule (just launch it), but you can manipulate the design and functionality of a VBA userform from a VBA form module (code), as well as from its graphical design interface.

Here are a couple of links you might find helpful related to iLogic forms.

To Work with Forms 

About Rules and Forms in iLogic 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7

Guido.LangeTuchscherer
Enthusiast
Enthusiast

Thanks again @WCrihfield ,

 

I would assume this can't be done within iLogic using Form, as I can not find out how to show several inpulistboxes at the same time or even in the same window then?

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

To include multiple multi-value drop down lists for the user to choose from, in an iLogic Form, you would need to create Parameters that are multi-value, then drag and drop those parameters over into your iLogic Form.  They will appear as drop down lists, so that when you run the form, the user can select from the values available within them.  The values need to be within those multi-value parameters though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 7

WCrihfield
Mentor
Mentor
Accepted solution

If you don't want to have to rely on multi-value parameters, and you only want to use a list of values that only exist within your code, then the ListBox of the VBA userform is likely what you will need.  Then within the VBA module for that userform, you can define and set the values that you want to be available within your ListBox, purely by code, without relying on existing parameters.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 7

matt_jlt
Collaborator
Collaborator
Accepted solution

There is another way to make custom vb.net forms in iLogic but it is a little bit more advanced and requires it to all be created in code.

 

Below is a very rough sample on how to do this (note that this is a bit of a jumble / mess but you can see basically how it works)

 

Public Class CustomForm
	Inherits System.Windows.Forms.Form
	
	Public myResult As String = "TestResultHere"
	Public myProp1 As String = "TestProperty"
	
	Public Sub New()
		' This is run when a new instance of the form is created
		
		oForm = Me
		
		With oForm
			' Set up form	
			.FormBorderStyle = FormBorderStyle.FixedToolWindow 'Fixed3D / FixedDialog / FixedSingle / FixedToolWindow / None / Sizable / SizableToolWindow
			'.MaximizeBox = False
			'.MinimizeBox = False
			.StartPosition = FormStartPosition.CenterScreen
			.Width = 600
			.Height = 500
			.TopMost = True
			.Text = "Custom Form"
			.Name = "Custom Form"
			
		End With
		
		Dim Button1 As New Button()
		With Button1
			'.Font = myfnt
			.Text = "test"
			'.Width = 100
			'.Height = 100
			.Top = 25
			.Left = 25
			.Enabled = True
		End With
		
		Dim oRb1 As New RadioButton()
		With oRb1
			.Text = "test radio btn 1"
			.Top = 150
			.Left = 50
		End With
		
		Dim oRb2 As New RadioButton()
		With oRb2
			.Text = "test radio btn 2"
			.Top = oRb1.Top + 20
			.Left = 50
		End With
		
		Dim oRb3 As New RadioButton()
		With oRb3
			.Text = "test radio btn 3"
			.Top = oRb2.Top + 20
			.Left = 50
		End With
		
		Dim oRb4 As New RadioButton()
		With oRb4
			.Text = "test radio btn 4"
			.Top = oRb3.Top + 20
			.Left = 50
		End With
		
		Dim oRb5 As New RadioButton()
		With oRb5
			.Text = "test radio btn 5"
			.Top = 10
			.Left = 10
		End With
		
		Dim oRb6 As New RadioButton()
		With oRb6
			.Text = "test radio btn 6"
			.Top = oRb5.Top + 20
			.Left = oRb5.Left
		End With
		
		Dim oRb7 As New RadioButton()
		With oRb7
			.Text = "test radio btn 7"
			.Top = oRb6.Top + 20
			.Left = oRb5.Left
		End With
		
		Dim oTB As New TextBox()
		With oTB
			.Text = "test radio btn 7"
			.Top = 10
			.Left = 300
		End With
				
		Dim oCB1 As New CheckBox()
		With oCB1
			.Text = "Check box 1"
			.Top = 40
			.Left = 200
		End With
		
		Dim myList As New List(Of String)
		myList.AddRange({"test1","test2","test3"})
		
		' Create a selection box and load list
		Dim oCombo1 As New ComboBox()
		With oCombo1
			.Items.Clear()
			.Items.AddRange(myList.ToArray)
			.SelectedIndex = 1
			.Top = 60
			.Left = 200
			.DropDownWidth = 300
			'.Width = 150
		End With
		
		' Create text box
		Dim textBox1 As New TextBox
		With textBox1
			.Multiline = True
			'.ScrollBars = VerticalScroll
			.Top = 80
			.Left = 200
			.Height = 200
			.Width = 300
			.AllowDrop = False
			.BorderStyle = BorderStyle.FixedSingle
			.WordWrap = True
			.ScrollBars = ScrollBars.Vertical
		End With
		
		'Add your Event handler
		AddHandler Button1.Click, AddressOf Button1_Click  
		
		'Add your Event handler
		AddHandler oRb1.Click, AddressOf RadioButton_Click
		AddHandler oRb2.Click, AddressOf RadioButton_Click
		AddHandler oRb3.Click, AddressOf RadioButton_Click
		AddHandler oRb4.Click, AddressOf RadioButton_Click
		AddHandler oRb5.Click, AddressOf RadioButton_Click
		AddHandler oRb6.Click, AddressOf RadioButton_Click
		AddHandler oRb7.Click, AddressOf RadioButton_Click
		

		oForm.Controls.Add(Button1)
		oForm.Controls.Add(oRb1)
		oForm.Controls.Add(oRb2)
		oForm.Controls.Add(oRb3)
		oForm.Controls.Add(oRb4)
		oForm.Controls.Add(oTB)
		oForm.Controls.Add(oCB1)
		oForm.Controls.Add(oCombo1)
		oForm.Controls.Add(textBox1)
		
		Dim oGB As GroupBox = New GroupBox()
		oGB.Left = 200
		oGB.Top = 200
		
		oGB.Controls.Add(oRb5)
		oGB.Controls.Add(oRb6)
		oGB.Controls.Add(oRb7)
		
		oForm.Controls.Add(oGB)
		
		' Set the first option to checked now it has beed added to form
		oRb1.Checked = True
		oRb7.Checked = True
		
		' Assign dialog result for the form (note this returns 0 based index of the enumerator
		Me.DialogResult = CustomDialogResult.Slope4
		'MessageBox.Show(GetGroupBoxCheckedButton(oGB).Text)
		
	End Sub
	
	Private Function GetGroupBoxCheckedButton(grpb As GroupBox) As RadioButton
	    For Each ctrl As RadioButton In grpb.Controls
	        If ctrl.Checked Then Return ctrl
	    Next
	End Function

	Private Sub CustomForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
	    If MessageBox.Show("Are you sure to close this application?", "Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = System.Windows.Forms.DialogResult.Yes Then
		
	    Else
	      e.Cancel = True
	    End If
	 End Sub
  
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal E As System.EventArgs)
		myResult = "testing clicked button"
		'sender.parent.Close ' Accesses the form and closes after button click
		' Can also direct cast to object "DirectCast"
		Dim ores As CustomDialogResult = CustomDialogResult.Slope2
		MessageBox.Show(ores.ToString)
		
	End Sub
	
	Private Sub RadioButton_Click(ByVal sender As System.Object, ByVal E As System.EventArgs)
		myResult = "RadioButtonClicked"
		'sender.parent.Close ' Accesses the form and closes after button click
		' Can also direct cast to object "DirectCast"
		'Dim ores As CustomDialogResult = CustomDialogResult.Slope2
		MessageBox.Show(myResult.ToString)
		
	End Sub


'	Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
'	    MyBase.OnMouseMove(e)
'	    MsgBox("Testing OnMouseMove()")
'	End Sub

	' Create a custom enumerator for windows for result
	Public Enum CustomDialogResult
	        Slope1
	        Slope2
	        Slope3
	        Slope4
	End Enum

End Class
	
Public Class RunMyForm
	
	Private Sub Main
			' Create new instance of the custom form
	        Dim myfrm As New CustomForm
			
			' Use ShowDialog so it waits for user / form close before continuing
			'MsgBox(myfrm.ShowDialog())
			
			Dim oResult As CustomForm.CustomDialogResult = myfrm.ShowDialog
			
			' Display the custom form result
			MessageBox.Show(oResult)
	    End Sub
End Class

 

Message 7 of 7

WCrihfield
Mentor
Mentor

Great point @matt_jlt .  I completely forgot to mention going the longer route of defining your own Windows Form using VB.NET (which is the basis of iLogic code) to create a custom solution that would be independent of both the other more common solution's restrictions.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes