MsgBox and If-statement

Hi all.

I want to make an “If-Else” statement that:

-If it is true, display the messagebox.
-If False, continue with the script.

How can I implement the If node in here?

In a previous question, @john_pierson suggested me this solution, but I don’t know how can I apply this here.

Thanks in advance.

Here is an all python way with a true/false toggle as well.

import clr
import msvcrt

clr.AddReference("RevitAPIUI")
from  Autodesk.Revit.UI import *

button = TaskDialogCommonButtons.None
result = TaskDialogResult.Ok
if IN[0] == True:
	TaskDialog.Show('User Text',IN[1],button)
	result = IN[1]
else:
	result = "Set run to true"
		
OUT = result

and in action

4 Likes

@john_pierson, @erfajo, nice solutions! Almost What I wanted. The only thing left is, when you go to the “else” part, is there a way to break the script at that point, so it doesn’t have to go further lacking the input elements?

Thanks

Hi @john_pierson. What does the line “button = TaskDialogCommonButtons.None”?

I commented this and excluded the button call, and got the same result.

image

1 Like

Yes, but:

import clr
import msvcrt

clr.AddReference("RevitAPIUI")
from  Autodesk.Revit.UI import *

result = TaskDialogResult.Ok
if IN[0] == True:
	TaskDialog.Show('User Text',IN[1])
	result = IN[1]
else:
	result = "Set run to true"
		
OUT = result

this solution gets the same result. So why did you put it?

1 Like

Honestly. I can’t tell you. It has been a while and I am pretty sure that code came from the code samples.

2 Likes

Ok. I’ll dig around. Thanks!

My version has the boolean built into it. Search Packages for “truevis”.

image

Thanks for the explanation. Much clearer now.

1 Like

How apply TaskDialogIcon ?
http://www.revitapidocs.com/2018/6c3246ba-2a00-386e-1ec4-39cdb7ad664e.htm

dialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning

How use it exactly? its my incorrect try

	Icon_ = TaskDialogIcon.TaskDialogIconWarning
	TaskDialog.Show("text1",  "text2", Icon_)
2 Likes