Python Yes/No Dialog Box?

I’m using the Rhythm Package which has this UI.UserMessage node. I’ve pulled the Python script out of it and am trying to get it so that it will display a ‘Yes’ and a ‘No’ button on the Dialog Box. I am having trouble, so far I am only able to input one button at a time. Does anyone have any experience with

import clr
import msvcrt

from  Autodesk.Revit.UI import *

import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

import Revit

dialogContent = "You are about to delete all Fabrication Pipework content from the model. Are you sure?"
button = TaskDialogCommonButtons.Yes
result = TaskDialogResult.value__

TaskDialog.Show('Delete all MEP',dialogContent,button,result)

OUT = result

Python’s RevitUI?

The Python window to the Left is the original code

Have you tried datashapes package maybe that has something you could use


Luckily, I made that Rhythm node. :wink: And it is long retired, so your version is WAAAAY old BTW.

That being said, it sounds like you want to return true or false depending on the Yes/No selection. Here is how to do that.

The python code in action:

and the actual code for copy pasta:

import clr

from  Autodesk.Revit.UI import *

dialogContent = "You are about to delete all Fabrication Pipework content from the model. Are you sure?"
buttons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No

#assigning this to a dialog result variable allows us to check what the user selected
dialogResult = TaskDialog.Show('Delete all MEP',dialogContent,buttons)

#define a return value parameter for use as an output
returnValue = False;

#if the user clicks yes, return true to continue
if dialogResult == TaskDialogResult.Yes:
	returnValue = True
OUT = returnValue

I will second @simon_murphy1 and suggest Data-Shapes package.


@simon_murphy1 I don’t mind the DataShapes window, but I was looking for just a simple quick dialog box. I actually just set a dialog box with DataShapes.

@john_pierson you’re the Man!! That is exactly what I was looking for! Thank you so much, I’ll have to re-download the package then lol

1 Like