How to execute C# Result.Cancelled in pyRevit and Python?

Hi everyone. I’m new at Python and pyRevit. I used to write macros for Revit using C#. I would like to know how do I have to do if, in a the midle of the script, I want to cancel the scrip because something it’s not the way it was expected. In C# I would do this with de Result.Cancelled command.

Hi, I guess enclosing your command in a try: … except:… would do.
you could find a few example in pyrevit documentation

or in the pyrevit code base as well

Thanks @Jean-Marc ! I’ll take a look at your links and tell you. Thanks a lot!