Ilogic question form

Ilogic question form

tegstette
Advocate Advocate
858 Views
6 Replies
Message 1 of 7

Ilogic question form

tegstette
Advocate
Advocate

HiSmiley Happy

 

I want to create an external iLogic rule that is triggered to New Document.

When the users start a New  file I want them to make some mandatory Choices and fill out some Properties.

 

This will set up the file accordingly, and each Choice can result in one or more settings, e.g.:

Reference drawing "No" will set a property to <Part Number>, "Yes" will set the Default BOM structure in Document Settings to 'Reference'

Sertification "Type 3" will create and set value to Sertification-property to "Type 3"

I would also like to have the possibility to fill out some property text, e.g. Project

Etc.

 

I think I can manage to make the ilogic-functions by doing  this sequently "one question at the time". But is there some way of setting this up in one "go", so the user can make all the Choices and then hit OK?

 

I do not want to add extra (unnecessary) Properties or (multivalue)parameters into the files to make it work.

Anyone who can give me some pointers on this?

 

 

 

 

Reference drawing?YesNo   Boolean

Sparepart?

YesNo   Boolean
Safety part?YesNo   Boolean
Machining?YesNo   Boolean
Sertification?Type 1Type 2Type 3Type 4 Multiple Choice (by check boxes?)
Project <free text>    

Free text

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
859 Views
6 Replies
Replies (6)
Message 2 of 7

yvandelafontaine
Advocate
Advocate

you could use an ilogic form.

 

make it modal so the user cannot do anything else until he hit ok

 

create multilist value in the parameter and call them in the form, or have ilogic create those value if they are missing with a try - catch condition

 

look into the attached file for an example of something you can do, i don't have much time right now but it should guide you on the right path.

 

the included file pop a message only the first time it is inserted in an assembly, the user has to place it, then select configuration option, and upon pressing done it save a copy of the file in a given path.

 

Hope it helps.

 

I you found this helpful define this awnser as solution and i always like kudos!

0 Likes
Message 3 of 7

tegstette
Advocate
Advocate

Thank you Yvan for Your input on the topicSmiley Happy

 

The form-display and functionality is what I am after. But I was trying ot avoid creating lots of multi-parameters into the file to make it work. Do you know if it is possible to somehow have the "multiparameters-list" just in the ilogic rule script and not in the inventor-file?

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 4 of 7

Owner2229
Advisor
Advisor

Hey, you can create these parameters dynamically on start by the rule and remove them after the form closes and you read the values.

 

For anything else you you'll have to use VBA or create an AddIn.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 5 of 7

tegstette
Advocate
Advocate

Yes, thank you for this inputSmiley Happy

 

I had it in mind this could be a solution if there was no alternative. 

My original use for this rule is when starting a New template, so here I do not have any conserns of this Method...

 

But I also would like to use a similar functionality by doing some "controls/checks" etc and my concern then is that the files will be dirty, because it has to create the multiparameters in the actual files.

 

So if you or someone else has an alternative "creative way" of doing this I am very glad for ideas...

 

But it seems like there is no obvious alternative way of doing this, so I may start on the create/dele-Method.

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 6 of 7

Owner2229
Advisor
Advisor

There's one more option. But it's a bit complicated. Watch and learn:

 

 

Imports System
AddReference "System.Drawing.dll"
Imports System.Windows.Forms

Sub Main()
	CreateForm()
	MF.ShowDialog
	MsgBox("ComboBox one value: " & CB(0).Text & vbNewLine & "ComboBox two value: " & CB(1).Text)
End Sub

Private MF As Form
Public CB(0) As ComboBox

Private Sub CreateForm()
	MF = New Form
	MF.Size = New System.Drawing.Size(500, 300)
	MF.Font = New System.Drawing.Font(MF.Font.FontFamily, 10)
	AddLabel(5, 5, "Paramter One")
	AddLabel(5, 40, "Paramter Two")
	AddCB(120, 5, {"Option one", "Option two"})
	AddCB(120, 40, {"Option three", "Option four"})
	
	AddExitButton()
End Sub

Private Sub AddLabel(PosX As Integer, PosY As Integer, Caption As String)
	Dim LC As Integer = MF.Controls.Count + 1
	Dim L1 As New Label
	L1.Name = "L" & LC
	L1.Location = New System.Drawing.Point(PosX, PosY)
	L1.Text = Caption
	MF.Controls.Add(L1)
End Sub

Private Sub AddCB(PosX As Integer, PosY As Integer, Values() As String)
	Dim LC As Integer = CB.Length - 1
	If Not CB(LC) Is Nothing Then
		LC = LC + 1
		ReDim Preserve CB(LC)
	End If
	CB(LC) = New ComboBox
	CB(LC).Location = New System.Drawing.Point(PosX, PosY)
	CB(LC).Name = "CB" & LC
	For Each Value As String In Values
		CB(LC).Items.Add(Value)
	Next
	MF.Controls.Add(CB(LC))
End Sub

Private Sub AddButton(PosX As Integer, PosY As Integer, Caption As String)
	Dim LC As Integer = MF.Controls.Count + 1
	Dim BT As New Button
	BT.Name = "BT" & LC
	BT.Location = New System.Drawing.Point(PosX, PosY)
	BT.Text = Caption
	MF.Controls.Add(BT)
End Sub

Private Sub AddExitButton()
	Dim LC As Integer = MF.Controls.Count + 1
	Dim BT As New Button
	BT.Name = "BT_Exit"
	Dim PosX As Integer = MF.Width * 0.8
	Dim PosY As Integer = MF.Height * 0.75
	BT.Location = New System.Drawing.Point(PosX, PosY)
	BT.Text = "OK"
	MF.Controls.Add(BT)
	AddHandler BT.Click, AddressOf Me.ExitButtonClick
End Sub

Private Sub ExitButtonClick()
	MF.Close()
End Sub

 

 

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 7 of 7

Anonymous
Not applicable

So the template file would just need a local rule to grab the parameters when a new document is created.  If you don't want to "dirty" your pristine file with extra parameters, then you would need to have input prompts that activate as the rule runs.

 

For your free text, you would need code like:

Dim project As String = InputBox("Project:","iLogic Template", "")

Then you would need to put that into an iProperty such as:

iProperties.Value("Project", "Project") = project

For the rest, you could just use a messagebox

 

referencebool = MessageBox.Show("Reference model?","iLogic Template", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

 Then do your If Then statement:

If referencebool = vbYes Then
'Insert code here
End If

For the multiple choice, I believe you could use the messagebox as well.  I haven't experimented with this but it might lead you in the correct direction:

 

sertbool = MessageBox.Show("Sertification?","iLogic Template", MessageBoxDefaultButton.Button1,MessageBoxDefaultButton.Button2,MessageBoxDefaultButton.Button3,MessageBoxDefaultButton.Button4,MessageBoxIcon.Question)

If that doesn't work then you'll have to use the multi-value parameter and link it to your form.

 

At least by using the messageboxes you won't have to create any parameters that aren't already there.  For the free text, you could even just link that iProperty to the form so that you don't have to code it at all.

0 Likes