Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to detect if user pressed yes/no/cancel in iLogic form?

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
psp
Enthusiast
3723 Views, 8 Replies

How to detect if user pressed yes/no/cancel in iLogic form?

How do I detect wich button the user pressed in the iLogic-form?

 

I can show it like this:

result=iLogicForm.ShowGlobal("MyForm", FormMode.Modal)

 I guess that result is of type FormReturnValue - but I can't guess the qualifier (FormReturnValue.OK / FormReturnValue.OkBtn / ?)

8 REPLIES 8
Message 2 of 9
psp
Enthusiast
in reply to: psp

Isn't there any way to detect what button is pressed? 

I have a lot of stuff in my rule, so it will run for some time after the user closes the form. That is why I want to give the user a chance to cancel the dialog.

The documentation says "similar to System.Windows.Forms.DialogResult - but typecasting isn't possible.

Autodesk.iLogic.Interfaces.xml:

<member name="T:Autodesk.iLogic.Interfaces.FormResult">
<summary>
A return value of a form: usually indicates which button caused the form to be closed.
</summary>
<remarks>
This is similar to System.Windows.Forms.DialogResult.
See FormReturnValue for the full return value.
</remarks>
</member><member name="T:Autodesk.iLogic.Interfaces.FormReturnValue">
<summary>
The full form return value, including the FormResult. If Result is RuleButtonClose or RuleButtonApplyAndClose, RuleName
will contain the name of the rule that is associated with the rule button that caused the form to close.
</summary>

 

Any help is welcome!

Poul

Message 3 of 9
Vladimir.Ananyev
in reply to: psp

Try this variant:

Dim Question As String = "Do you like iLogic?"
Dim Title As String = "iLogic Forms"

Dim R As System.Windows.Forms.DialogResult 
R = MessageBox.Show(Question, Title,  _
		MessageBoxButtons.YesNoCancel, _
		MessageBoxIcon.Question, _
		MessageBoxDefaultButton.Button1)

Dim St As String
Select Case R 
	Case vbYes
		St = "Yes"
	Case vbNo
		st = "No"
	Case vbCancel
		st = "Cancel"
	Case Else
		st = "Something unexpected.  Error?"
End Select

'results visualization
MessageBox.Show( st, title,  _
       MessageBoxButtons.OK, MessageBoxIcon.Asterisk)

iLogic rules editor has the wizard for MessageBox expressions.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 4 of 9
psp
Enthusiast
in reply to: Vladimir.Ananyev

Thank you for your input. But this is just handling result from an ordinary .Net messagebox.

My problem is to detect what is pressed in an iLogic-form, not a messagebox.

I have forms where i can change my fx-parameters etc.

 

 

PSP

Message 5 of 9
Vladimir.Ananyev
in reply to: psp

Create modal form with name "Form 1" and run this rule:

'run for modal form "Form 1"
Dim R As FormReturnValue  = iLogicForm.Show("Form 1")

Dim St As String
Select Case R.Result.tostring
	Case "Cancel"
		st = "Cancel"
	Case "OK"
		st = "OK"	
	Case "Close"
		st = "Close"		
	Case Else
		st="???  " & R.Result.tostring 		
End Select
MsgBox(st )

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 6 of 9
psp
Enthusiast
in reply to: Vladimir.Ananyev

Excellent - thank you!

Message 7 of 9
afredrik
in reply to: psp

Hello,

 

I was glad I finally found a solution for this problem. But unfortunately it doesn't work. I copied and pasted the code into a rule and made a nodal form called 'Form 1' as told in the description of Vladimir

 

But I always immidiately get the messagbox showing: ??? None. I don't get the chance to click any button at all.

 

I tried it with different buttons in the form but nothing works. I need to be able to cancel the rule from completion when clicking the cancelbutton in the form.

 

Who can help me?

 

 

Best regards,

 

Antwan

Message 8 of 9
VdVeek
in reply to: afredrik

If you create 2 rules, one for Ok and one for Cancel and use these in your Form instead of the default Predifined Buttons you are totaly in control of the actions when the user pressed a button.

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 9 of 9
afredrik
in reply to: VdVeek

Hello Rob,



Thanks, for the reply. But if I understand you correctly I than have two
separate rules. This form I am using is called from a main rule. How do I
get the outcome of the two 'Yes' and 'Cancel' rules into the main rule where
the Form was called from?





With kind regards,



Antwan Fredrik



Engineering/Production automation

Mob: +31 (0) 6 57 99 50 03



Beschrijving: Beschrijving: Beschrijving: Briefhoofd Van Wamel





Beschrijving:
cid:image002.jpg@01CBEA31.9C3B2510



P Denk aan het milieu alvorens te besluiten deze e-mail te printen.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums