# Extract Warnings using Dynamo

**URL:** <https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [May 5, 2020, 11:48am UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242 "2020-05-05T11:48:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![johan.germishuys](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@johan.germishuys](https://forum.dynamobim.com/u/johan.germishuys)\
**Post date:** [May 5, 2020, 11:48am UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/1 "2020-05-05T11:48:43Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/0/a0d6e0703939f7860e098c558f364fd3e1faa549.png)

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

---

<div class="post-metadata">

**Author:** ![johan.germishuys](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@johan.germishuys](https://forum.dynamobim.com/u/johan.germishuys)\
**Post date:** [May 5, 2020, 11:49am UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/2 "2020-05-05T11:49:21Z")

</div>

Here is a screenshot showing the data in Dynamo.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/6/168fcd6f6b48d8df0b27e85c8659c55e071beeb6.png)

---

<div class="post-metadata">

**Author:** ![cgartland](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cgartland/32/45378_2.png) [@cgartland](https://forum.dynamobim.com/u/cgartland)\
**Post date:** [May 5, 2020, 1:14pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/3 "2020-05-05T13:14:11Z")

</div>

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().

---

<div class="post-metadata">

**Author:** ![johan.germishuys](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@johan.germishuys](https://forum.dynamobim.com/u/johan.germishuys)\
**Post date:** [May 5, 2020, 1:22pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/4 "2020-05-05T13:22:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cgartland](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cgartland/32/45378_2.png) [@cgartland](https://forum.dynamobim.com/u/cgartland)\
**Post date:** [May 5, 2020, 2:20pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/5 "2020-05-05T14:20:03Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![johan.germishuys](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@johan.germishuys](https://forum.dynamobim.com/u/johan.germishuys)\
**Post date:** [May 5, 2020, 3:23pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/6 "2020-05-05T15:23:26Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/a/fa5956736c50a2e36f86f7b0306294c30e631a6a.png)

---

<div class="post-metadata">

**Author:** ![cgartland](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cgartland/32/45378_2.png) [@cgartland](https://forum.dynamobim.com/u/cgartland)\
**Post date:** [May 5, 2020, 3:57pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/7 "2020-05-05T15:57:54Z")

</div>

Looks like the code itself in either case is not the problem, rather this hints at a larger issue. [This thread](https://forums.autodesk.com/t5/revit-api-forum/revit-api-quot-get-warning-quot-method-does-not-get-parent/td-p/9193191) on the Revit API forum may help you, but it doesn’t address your exact situation.

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [May 5, 2020, 4:06pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/8 "2020-05-05T16:06:05Z")

</div>

Hi @johan.germishuys

Here you tried using OOTB nodes Performance Adviser Rules?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/0/30553d36b821269e5ea22e0ada2631b6ad3c8448.png)

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [May 5, 2020, 4:27pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/9 "2020-05-05T16:27:50Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![johan.germishuys](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@johan.germishuys](https://forum.dynamobim.com/u/johan.germishuys)\
**Post date:** [May 5, 2020, 4:29pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/10 "2020-05-05T16:29:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [May 5, 2020, 4:49pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/11 "2020-05-05T16:49:45Z")

</div>

This came up recently on the Bang! Issues page, here. [https://github.com/johnpierson/BangForDynamo/issues/2](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

---

<div class="post-metadata">

**Author:** ![johan.germishuys](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@johan.germishuys](https://forum.dynamobim.com/u/johan.germishuys)\
**Post date:** [May 5, 2020, 6:11pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/12 "2020-05-05T18:11:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [May 5, 2020, 6:20pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/13 "2020-05-05T18:20:18Z")

</div>

the code for Bang is literally in the link I posted 😅

Here it is for completeness:

> <https://github.com/johnpierson/BangForDynamo/blob/0171ae0b4ea5d0130cdbc12c192d313b8aa1e078/src/Bang/Revit/Elements/Warning.cs#L45-L61>

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.

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [May 5, 2020, 7:15pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/14 "2020-05-05T19:15:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ziyun.shang](https://avatars.discourse-cdn.com/v4/letter/z/76d3ee/32.png) [@ziyun.shang](https://forum.dynamobim.com/u/ziyun.shang)\
**Post date:** [May 6, 2020, 9:30am UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/15 "2020-05-06T09:30:59Z")

</div>

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

 ![Extract Warnings using Dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/5/05dfa959cc303f65d16cb8cabebc0035c11e606f.png)  
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.

---

<div class="post-metadata">

**Author:** ![johan.germishuys](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@johan.germishuys](https://forum.dynamobim.com/u/johan.germishuys)\
**Post date:** [May 6, 2020, 9:35am UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/16 "2020-05-06T09:35:44Z")

</div>

@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](#):
>
> Method 3 : HTML Warning Export
> 
> ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/0/a0d6e0703939f7860e098c558f364fd3e1faa549.png)

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [May 6, 2020, 1:20pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/17 "2020-05-06T13:20:32Z")

</div>

@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 🙂

---

<div class="post-metadata">

**Author:** ![ziyun.shang](https://avatars.discourse-cdn.com/v4/letter/z/76d3ee/32.png) [@ziyun.shang](https://forum.dynamobim.com/u/ziyun.shang)\
**Post date:** [May 7, 2020, 8:13am UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/18 "2020-05-07T08:13:58Z")

</div>

@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.

 ![ImprovementInPythonCode](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/9/3985eeb774dc94816a267ed372f97dd3952669c8.png)

```
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
```

---

<div class="post-metadata">

**Author:** ![johan.germishuys](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@johan.germishuys](https://forum.dynamobim.com/u/johan.germishuys)\
**Post date:** [May 7, 2020, 12:37pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/19 "2020-05-07T12:37:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [May 7, 2020, 3:15pm UTC](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242/20 "2020-05-07T15:15:29Z")

</div>

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

[Next page](https://forum.dynamobim.com/t/extract-warnings-using-dynamo/50242.md?page=2)
