Check Message box to call Form and don't close drawing

Check Message box to call Form and don't close drawing

projeto1LKKGD
Participant Participant
514 Views
2 Replies
Message 1 of 3

Check Message box to call Form and don't close drawing

projeto1LKKGD
Participant
Participant

Hello,

 

I have some Custom Properties in a drawing, I created a form to change these properties.

I create the following rule to call this form and it triggered after open document, before saving it and closing it.

When clicking "yes", I want opening the form, when "no", continue saving/closing.

 

Sub Main ()
oQ=MessageBox.Show("Queres verificar se os dados de legenda estão corretos?", "Atenção",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
	If oQ = vbYes
		iLogicForm.Show("DADOS LEGENDA")
	End If
End Sub

The issue is when closing, I select "Yes" button, the form is shown, but the drawing is closed anyway.

0 Likes
Accepted solutions (1)
515 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @projeto1LKKGD.  That is a tough one.  For starters, when using regular iLogic Forms, you can choose to show the form as 'Modal', or not.  If shown Modal, the code that launched it will be paused while that form remains open, and this allows you to capture how the form was closed, and to be able to react to the forms closure.  Below is an expanded version of your original code above.

Sub Main ()
	oQ=MessageBox.Show("Queres verificar se os dados de legenda estão corretos?", "Atenção",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
	If oQ = DialogResult.Yes Then
		'to do something after the form closes, show it as Modal, then capture its return value
		Dim oFRV As FormReturnValue = iLogicForm.Show("DADOS LEGENDA", FormMode.Modal)
		'now you can check the return value to check how it was closed, and react to its closure
		If oFRV.Result = FormResult.Done Then
			Logger.Info("You clicked the 'Done' button on your 'DADOS LEGENDA' form.")
		ElseIf oFRV.Result = FormResult.OK Then
			Logger.Info("You clicked the 'OK' button on your 'DADOS LEGENDA' form.")
		End If
	End If
End Sub

However, if you want to be able to cancel saving or cancel closing a document, you will need to use almost completely different, and more complex code solution.  When using the Event Triggers dialog box to run iLogic rules, you do not have any control over that event, so you can not prevent that event from continuing to do its task after your rule runs.  You would have to use actual custom event handler code, which has direct access to that real Event itself, to have that level of control.  I have attached a PDF of one of my old contribution posts about working with event handlers in vb.net / iLogic.  The documentation needs to be updated, but has some good information.  Within the event handler block of code, you have access to the timing of before or after the event (Link), and a tool (Link) that can be used to cancel the event.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

projeto1LKKGD
Participant
Participant
Thanks. For now, this worked for my needs. I'll check your PDF with properly time for further improvements and come back here if I get a solution.
0 Likes