I am working on a pyRevit script for bulk upgrade of all files in a specified folder. As the script closes all worksets upon openings a central file, no pop up messages would appear in this case.
However, if the file encountered is not central, many Dialogs appear, blocking the script until the user specifies a value for the specific update. As I noticed all of the dialogs upon opening are usually of type ‘Dialog_Revit_DocWarnDialog’, I tried to specify a default value for all of them, which was 1001. However, sometimes the first button in the dialog is not the one we need to press, so I had to go deeper and specify a different value, depending on the dialog message.
I tried adding an object of type TaskDialogShowingEventArgs, so that I can get the event.Message(), like shown in this example: Auto dismiss task dialog - YouTube
As I am more of a C# guy, I am currently failing to translate this line in Python:
You will probably have better luck on pyrevit forums given this is a pyrevit question. Look into the errorswallower class in pyrevit as that might help deal with these.
Theres a good thread here with some tips/warnings about using the ifailureprocessor or derivative versions of it as well, read well:
I am trying to avoid using pyRevit classes and functions, but base my scripts on the RevitAPI entirely. In that sense, even though this script works under pyRevit, it doesn’t really use anything from it (actually one single thing - the form to pick up folders).
In that sense, I think it’s a general API question and I found my answer within the API, been just struggling to translate it into Python ( if you ask anything Python related in the API forum, you usually get the answer to go ask in the dynamo forum instead )
Pretty much everything available in pyrevit is actually written quite raw in its libraries if you go digging, but no worries! I’ve learnt a lot about the API by digging through lots of the py files and tools.
Easier to see how it can be applied sometimes. I use both, but not everything in the api is very intuitive until you see it in a practical scenario I find.
Instead of swallowing the error (usually a bad practice - they pop up for a reason after all) you might want to consider checking to see if the file is workshared. If so use the current method you’re working with, and if not use a different method (avoiding the workset issue and others) to process the file.
Start by extracting the basic file info from the document with this method: Extract Method. Then after you have the basic file info object get the worksharing status with this property: IsWorkshared Property.
As an added benefit while you’re working with the basic file info object you can get a bunch of other useful data, such as the file format (Revit release year), if all changes have been saved to the central (ensuring that no one has work locally saved but not synced before you upgrade), and what version the file is (how many times it’s been saved).
Hi, the worksets issue is not a thing, the problem is with messages of this kind:
etc.
And they would still appear when following the workflow you are mentioning. Maybe you see in my code that I wanted to try overriding the pop up message result with 1001 in any case. However, this is not ok, as it means for example ‘delete rooms’ in certain cases. That’s why I think the method I need to use is the one mentioned above, in the youtube video.
I just can’t translate it in Python, so I have no choice but to try with the pyRevit method and see if it helps if not, I will have to rewrite the script in C#, I just wanted to avoid having to do that
Those warnings appear related to links either not loading that bound rooms and/or references being lost. Test carefully with error swallowing as i believe it may potentially use deletion options to bypass them sometimes.
yeap, I will definitely check if they are dismissed properly, but I see I might have to recreate it in C#, so that I can properly explore the error messages and the ‘correct’ answer to each. Another example of an error one might get upon opening:
I realised why you were asking that, it’s cause I mentioned they do not appear for central models What I meant was when all worksets are closed upon opening the file, there is basically nothing that could go wrong. For instance, if all dimensions are in a closed workset, there is no way any of them would lose its reference, etc. At least, while testing, I couldn’t find a single workshared model, producing any of these errors with this workflow. But still, it doesn’t depend on the workshared status, but the fact the script is closing all worksets
This query has come up quite a few times now on threads. The failures processor mentioned by Cyril above is the only option offered in Revit to deal with this to my understanding.
If you’re trying to figure out how to implement it, I’d suggest looking at the pyRevit error swallower which packages it up very neatly. See bottom of this py file for how Ehsan makes it into a class: