# Warnings from linked models

**URL:** <https://forum.dynamobim.com/t/warnings-from-linked-models/31422>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [January 30, 2019, 11:07am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422 "2019-01-30T11:07:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![klausvm](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@klausvm](https://forum.dynamobim.com/u/klausvm)\
**Post date:** [January 30, 2019, 11:07am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/1 "2019-01-30T11:07:07Z")

</div>

Hi

I was wondering if it was possible to get warnings from linked model? It’s a bit comprehensive and tedious to open several models in a project and run a script, so it would be nice to be able to collect the warnings from the linked models and output them in a single Excel file.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [January 30, 2019, 11:32am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/2 "2019-01-30T11:32:47Z")

</div>

dont know if it works for linked models, but have you tried the Bang package?

> **[Bang! for Dynamo](http://sixtysecondrevit.com/2017-04-27-bang-for-dynamo/)**
>
> Bang! for #DynamoBIM Well, Revit 2018 came out recently and there were a few exciting API additions. One of these included the ability to access warnings a little easier. As a result of this new ability, I went ahead and published a new Dynamo...

---

<div class="post-metadata">

**Author:** ![klausvm](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@klausvm](https://forum.dynamobim.com/u/klausvm)\
**Post date:** [January 30, 2019, 11:36am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/3 "2019-01-30T11:36:25Z")

</div>

Yes I have tried the Bang! package, it does not include warnings from Revit links - unfortunately.

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [January 30, 2019, 11:55am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/4 "2019-01-30T11:55:36Z")

</div>

@klausvm  
Unfortunate indeed. @john_pierson  
Maybe you could try to batch opening your files in the background (over night) and writing warning reports.

---

<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:** [January 30, 2019, 1:22pm UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/5 "2019-01-30T13:22:18Z")

</div>

> [@Marcel\_Rijsmus](#):
>
> Maybe you could try to batch opening your files in the background (over night) and writing warning reports

Unfortunately, the way Bang is written it will only work on the current document and I don’t plan on changing that in the package. The main reason is because the UI nodes simply use the active document since there is no input for a `Document` element. Another issue is that Bang was created to help provide framework to _resolve_ warnings. When you have background opened documents, it is very difficult to make changes to them and that would become very difficult to manage.

If I were to entertain the idea of adding Document inputs to warning nodes there would be a pretty large disclaimer that it is only for queries. Let me think on that one some more.

* * *

That being said, the method I am using is [Document.GetWarnings](https://apidocs.co/apps/revit/2019/4774613d-600a-e1b5-b5aa-f1ee3b14394c.htm) which was added to the Revit 2018.1 API. That method _ **does** _ take a document and I do not see why someone couldn’t build nodes (Python or C#) that could handle that.

---

<div class="post-metadata">

**Author:** ![klausvm](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@klausvm](https://forum.dynamobim.com/u/klausvm)\
**Post date:** [January 31, 2019, 7:42am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/6 "2019-01-31T07:42:06Z")

</div>

> [@john\_pierson](#):
>
> Unfortunately, the way Bang is written it will only work on the current document and I don’t plan on changing that in the package. The main reason is because the UI nodes simply use the active document since there is no input for a `Document` element. Another issue is that Bang was created to help provide framework to _resolve_ warnings. When you have background opened documents, it is very difficult to make changes to them and that would become very difficult to manage.
> 
> If I were to entertain the idea of adding Document inputs to warning nodes there would be a pretty large disclaimer that it is only for queries. Let me think on that one some more.
> 
> That being said, the method I am using is [Document.GetWarnings](https://apidocs.co/apps/revit/2019/4774613d-600a-e1b5-b5aa-f1ee3b14394c.htm) which was added to the Revit 2018.1 API. That method _ **does** _ take a document and I do not see why someone couldn’t build nodes (Python or C#) that could handle that.

@john_pierson Thanks for your reply. I only want to make queries. My purpose is not to resolve warnings automatically. I have a Power BI dashboard with information gathered from the main model and the linked models. I just want to show statistics of the warnings and make my team aware of the amount, what categories they are and the ratings.

I have no experience with Python or C#, so making my own node would be quite hard at this point. I was only asking if the possibility already existed.

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [January 31, 2019, 7:52am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/7 "2019-01-31T07:52:41Z")

</div>

I have no experience with Bang but how would you want the node to output the warnings? [From here](https://apidocs.co/apps/revit/2019/092161ab-4f4a-f5ad-8c9f-7edcda0818fe.htm), you can see everything that can be extracted from a warning, including the description text and the element Id.

Going off the method @john_pierson gave and the linked doc collector from this thread [Revit link elements](https://forum.dynamobim.com/t/revit-link-elements/31290/12?u=kennyb6), courtesy of @cgartland, this python code will give you a list of warnings with their respective elementid from all of the linked docs.

```
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager

current_doc = DocumentManager.Instance.CurrentDBDocument
links = FilteredElementCollector(current_doc).OfClass(RevitLinkInstance)
docs = [link.GetLinkDocument() for link in links]

all_warnings = []
for doc in docs:
	warns = doc.GetWarnings()
	warnings = []
	for warn in warns:
		elems = []
		warnings.append(warn.GetDescriptionText())
		for elem in warn.GetFailingElements():
			elems.append(doc.GetElement(elem))
		warnings.append(elems)
	all_warnings.append(warnings)

OUT = all_warnings

```

Let me know what you would want added to the list.  
Edit: updated to return the actual element instead of elementid

![linkedwarnings](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/3/135efd9f3a431cad8faeb140ab662decd60be365.png)

---

<div class="post-metadata">

**Author:** ![klausvm](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@klausvm](https://forum.dynamobim.com/u/klausvm)\
**Post date:** [January 31, 2019, 9:29am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/8 "2019-01-31T09:29:38Z")

</div>

@kennyb6 That’s great, thank you - I knew there were some brilliant minds in here. I will try it out.

Can I filter the output? I have about 6 architectural links and the same amount of engineering models, which I don’t want to get the warnings from. So I would want to sort the warnings from the different models, so I can see which warnings come from which model.

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [January 31, 2019, 9:37am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/9 "2019-01-31T09:37:01Z")

</div>

Would you rather put an input on the python node that accepts the revitlinkedinstances / linked docs and then run it or run it and then filter afterwards?

For the latter, this graph will turn each linked instance into a dictionary of its warnings for which you can filter by name, etc.:

 ![linkedwarnings2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/b/5bbb79597f8242c65cfede4af7b7956c28e6faa8.png)  
[linkedwarnings.dyn](https://forum.dynamobim.com/uploads/short-url/1ksZU8ZGSMIp4XtBbJnplCsw4ty.dyn) (7.9 KB)

In this I was testing different outputs so that version currently outputs the description of the warning, the possible resolution (if none then it will say none available), and the severity. The dictionary name is the linked model’s name (something.rvt).

---

<div class="post-metadata">

**Author:** ![klausvm](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@klausvm](https://forum.dynamobim.com/u/klausvm)\
**Post date:** [January 31, 2019, 10:08am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/10 "2019-01-31T10:08:50Z")

</div>

I can easily filter it afterwards or just turn of the links I don’t want processed.

This is great. But when I try to run the script, it just keeps saying “Run started…” and has been like that for 30 minutes now… Any idea why?

Would be great also to have the element id from the warning, so it’s easy to lookup and locate.

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 1, 2019, 1:35am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/11 "2019-02-01T01:35:39Z")

</div>

I don’t know why the script freezes for you. I am using Dynamo 2.0.2 with Revit 2018 and it works fine for me. This version will give you dictionaries of each linked model with the description text, resolution, list of element ids, and severity, in that order.

[linkedwarnings.dyn](https://forum.dynamobim.com/uploads/short-url/nk0GmcYG0uCbAVS5BmUAjynlFSB.dyn) (7.9 KB)

Let me know if it still freezes for you.

---

<div class="post-metadata">

**Author:** ![klausvm](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@klausvm](https://forum.dynamobim.com/u/klausvm)\
**Post date:** [February 4, 2019, 9:12am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/12 "2019-02-04T09:12:05Z")

</div>

@kennyb6

I tried it on a different document and it worked just fine now. This is very very good - thank you.  
I just need to add warnings from the current model as well and assign the warnings to their respective levels. Can I assign the warnings based on the dictionary values or do I need to do that in the Python script?

Thank you so much!

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 8, 2019, 1:52am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/15 "2019-02-08T01:52:30Z")

</div>

Sorry, the office was closed for Chinese New Years, just got to this. Can you explain what you mean by assigning the warnings?

---

<div class="post-metadata">

**Author:** ![klausvm](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@klausvm](https://forum.dynamobim.com/u/klausvm)\
**Post date:** [February 11, 2019, 7:57am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/16 "2019-02-11T07:57:04Z")

</div>

No worries.  
I’m just trying to filter the output, so that all warnings have the correct model assigned to them.  
So when it’s transposed and exported to Excel, each line contains: model name, warning msg, warning solution, warning id’s.

---

<div class="post-metadata">

**Author:** ![mscottM6C4C](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mscottM6C4C](https://forum.dynamobim.com/u/mscottM6C4C)\
**Post date:** [February 11, 2019, 4:01pm UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/17 "2019-02-11T16:01:40Z")

</div>

This script also sometimes freezes for me.  
I am using Dynamo 2 and Revit 2018.3

I don’t know which triggers cause it to freeze.

 ![linkedwarningsdictionary](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/5/b5e2addad17f7d6ff4a97e7a4aab883a32f99fe7.jpeg)

---

<div class="post-metadata">

**Author:** ![mscottM6C4C](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mscottM6C4C](https://forum.dynamobim.com/u/mscottM6C4C)\
**Post date:** [February 11, 2019, 4:56pm UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/18 "2019-02-11T16:56:25Z")

</div>

In order to use this script, I believe you cant have _ANY_ unloaded links. The links must either be fully loaded or fully removed.

“Nulls” do not let the python script run.

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 12, 2019, 1:08am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/19 "2019-02-12T01:08:04Z")

</div>

Ah that makes sense. I never put in any error testing. You can add this after the `for doc in docs:` line:

```
	if doc == None:
		continue
```

---

<div class="post-metadata">

**Author:** ![mscottM6C4C](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mscottM6C4C](https://forum.dynamobim.com/u/mscottM6C4C)\
**Post date:** [February 27, 2019, 3:08pm UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/20 "2019-02-27T15:08:07Z")

</div>

Hello Kenny,

What changes would i need to make to run this on Dynamo 1.3?

I find that Dynamo 2.0 is unstable and prone to crash.

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 28, 2019, 1:10am UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/21 "2019-02-28T01:10:08Z")

</div>

Because dictionaries do not exist in 1.3, you would have to use a different way of organizing. The main script should work just fine, up until the Dictionary node. You can play with the outputs of the python or the codeblock to get the structure you want.

---

<div class="post-metadata">

**Author:** ![mscottM6C4C](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mscottM6C4C](https://forum.dynamobim.com/u/mscottM6C4C)\
**Post date:** [February 28, 2019, 8:17pm UTC](https://forum.dynamobim.com/t/warnings-from-linked-models/31422/22 "2019-02-28T20:17:21Z")

</div>

On second thought I will stay in 2.0.

For some reason Archilab package was causing my script to crash.

I have to rebuild without Archilab.
