Extract Warnings using Dynamo

Hi,

I’m trying to extract a list of Warnings from Revit using Dynamo. I’ve tried a number of methods, and I’ll list them down and describe the issue I’m experiencing.

Method 1: (Bang!)

Method 2 : (Python)
I use the following Python Script to extract Warnings.

import clr

"# Import DocumentManager and TransactionManager
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import ToDSType(bool) extension method

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

Import RevitAPI

clr.AddReference(“RevitAPI”)
import Autodesk
doc = DocumentManager.Instance.CurrentDBDocument

data = IN

Warnings=doc.GetWarnings()
description=
elements=

for i in Warnings:
description.append(i.GetDescriptionText ())
x = i.GetFailingElements()
sub=
for j in x:
sub.append(doc.GetElement(j))
elements.append(sub)

OUT = [description,elements]"

Method 3 : HTML Warning Export

This gives me the exact same results as the Bang Package. The issue I have is the following, the HTML Export from Revit identifies all the ElementID’s for all the Warnings. Using the methods through Dynamo does not identify all of them.

I’m currently using Revit 2019.2, with Dynamo 1.3

Here is a screenshot showing the data in Dynamo.

Would you be able to output the list of ElementIds themselves? Just want to make sure all warnings are returning ElementIds as the problem may be related to doc.GetElement().

Hi, that’s the exact issue I’m having. Not all the errors using the methods are giving me the related ElementID’s.

FailureMessage.GetFailingElements() returns a list of ElementIds. From there, you are getting the actual Element by using Document.GetElement(). If you output the actual list of ElementIds, rather than Elements, it may provide more insight. For example:

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

warnings = doc.GetWarnings()
descriptions = []
ids = []
elements = []

for warning in warnings:
    descriptions.append(warning.GetDescriptionText())
    ids_temp = warning.GetFailingElements()
    elements_temp = []
    for id in ids_temp:
        elements_temp.append(doc.GetElement(id))
    elements.append(elements_temp)
    ids.append(ids_temp)

OUT = descriptions, ids, elements

Hi, I’ve tried the script you provided. And I’m still only getting a small amount of ElementID’s.

image

Looks like the code itself in either case is not the problem, rather this hints at a larger issue. This thread on the Revit API forum may help you, but it doesn’t address your exact situation.

Hi @johan.germishuys

Here you tried using OOTB nodes Performance Adviser Rules?

I’ve passed this thread onto the Dynamo4Revit team to have a look at and see if the issue arises from the nodal implementation or the API itself :slight_smile:

Thank you Sol… I’m not sure if it might be related to the types of errors.

1 Like

This came up recently on the Bang! Issues page, here. https://github.com/johnpierson/BangForDynamo/issues/2

Specifically, hosted elements were giving issues and I implemented a workaround for that specific scenario.

I am betting we are seeing something similar with your use-case. I would also bet that you would see it work as expected in Revit 2020

1 Like

Hi John,

Could you share the workaround, as I’m using the latest version of Bang! to extract the errors? Also, I’m sure you saw the versions of Revit and Dynamo that I’m on.

the code for Bang is literally in the link I posted :sweat_smile:

Here it is for completeness:

Fair warning: I only implemented a fix for the specific sketch element error @Mark.Ackerley brought to my attention.


Will I add more fixes for the other errors you are encountering? Most likely not as it is an older version of Revit that you are using and an older version of Dynamo. I strongly suggest trying our your file in 2020 to see if it is still an issue.

2 Likes

It’s a very smart way of getting them :wink: thanks again John

Hi @solamour @johan.germishuys
I just try this python code on my side, it seems work well.


I’m using Revit 2019(19.2.0.66) with Dynamo 1.3.4.
Is this issue happening only for some specific Elements?
Do you experience this issue in the new version of Revit or Dynamo?
Preferably you can provide a Revit Sample file, I can reproduce it on my side.

@ziyun.shang, if you look at the list. The only one that gave me all the elementId’s was “ElementID’s have duplicate Type Mark values”.

The rest of the errors in the list, does not provide me with ElementID’s.

@johan.germishuys - Are you able to provide a sample Revit file that has these issues? Do the Revit Sample Files? It’s easier for us to debug and fix when it’s reproducible :slight_smile:

@johan.germishuys
Thanks to your sample files, I found that Revit Warning also use “GetAdditionalElements” in HTML Warning Export. I have improved your python code, and works well.

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

warnings = doc.GetWarnings()
descriptions = []
elements = []

for warning in warnings:
    descriptions.append(warning.GetDescriptionText())
    ids_temp = warning.GetFailingElements()
    elements_temp = []
    for id in ids_temp:
        elements_temp.append(doc.GetElement(id))
    aids_temp=warning.GetAdditionalElements()
    for id in aids_temp:
        elements_temp.append(doc.GetElement(id))
    elements.append(elements_temp)

OUT = descriptions, elements
3 Likes

Thank you very much @ziyun.shang, this is excellent. Hopefully @john_pierson can include this into Bang!. This Python script works in Dynamo 1.3 if others wanted to know.

Thanks for the heads up @johan.germishuys, added it now.

2 Likes