# Find CAD link referencing View

**URL:** <https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204>\
**Category:** Revit\
**Created:** [November 1, 2016, 4:51pm UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204 "2016-11-01T16:51:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon\_murphy1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/simon_murphy1/32/101536_2.png) [@simon\_murphy1](https://forum.dynamobim.com/u/simon_murphy1)\
**Post date:** [November 1, 2016, 4:51pm UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/1 "2016-11-01T16:51:39Z")

</div>

[GET VIEW NAME FOR SPECIFIC CAD LINK.dyn](https://forum.dynamobim.com/uploads/short-url/2361mPfnZNqUx0on0pNHjosNXna.dyn) (8.3 KB)

Find Referencing Views for Linked CAD files.

Hi I am trying to find the view that a CAD Link has been linked into. I have many views and it is not possible to search through each one to find the link.

I have had a go at it in dynamo and have used a few custom packages but not sure which ones.

At the moment I have been able to get all the links and then select the link I want from the list using a match string custom node. The python script at the end will copy an element from one view to another if you give it the view names and the element id. I am only missing the view name for the existing CAD link.

Thanks

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/e/7eceba9f32b51981bdc0ebfd086224cc538c7fea.png)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [November 1, 2016, 7:52pm UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/2 "2016-11-01T19:52:03Z")

</div>

This should get you started so you’ll need to think about how to iterate through your list of views and query if the collector returns an ImportInstance. Note that the way the DWG has been linked will affect the result of your query. Unless it’s been linked to the current view when it was first imported, you’re going to get lots of views reporting a DWG link when only one object exists in your model, meaning what you are asking for might be flawed from the outset anyway if you are expecting to find one DWG associated to one view:

```
import clr

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

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

view = UnwrapElement(IN[0])

collector = FilteredElementCollector(doc, view.Id).OfClass(ImportInstance)
collector.ToElements()

OUT = collector
```

---

<div class="post-metadata">

**Author:** ![simon\_murphy1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/simon_murphy1/32/101536_2.png) [@simon\_murphy1](https://forum.dynamobim.com/u/simon_murphy1)\
**Post date:** [November 2, 2016, 10:16am UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/3 "2016-11-02T10:16:23Z")

</div>

[GET VIEW NAME FOR SPECIFIC CAD LINK.dyn](https://forum.dynamobim.com/uploads/short-url/tsg10L5xO5ycnBOohUJwJ3FuiMe.dyn) (19.6 KB)

Hi Thanks for the help. I have used a LoopWhile Node to iterate through your python script. First time to get it to work very exciting, thanks. My next problem is how to adjust the python script to select to import instance I want to search for, but for now this does what I needed, thanks again.

---

<div class="post-metadata">

**Author:** ![simon\_murphy1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/simon_murphy1/32/101536_2.png) [@simon\_murphy1](https://forum.dynamobim.com/u/simon_murphy1)\
**Post date:** [March 13, 2018, 4:57pm UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/4 "2018-03-13T16:57:33Z")

</div>

Hi,

I am still trying to find a solution for this. I have learnt a little bit of python since last time. But it doesn’t seem to be working for me. Hope someone can help with the python. I need to find the location of a specific link based on the name of the CAD link.

dynamo file at bottom

doc = DocumentManager.Instance.CurrentDBDocument

ownerViewId = “Owner View : N/A”  
namsearch = UnwrapElement(IN[0])  
views = UnwrapElement(IN[1])

for view in views:  
cadLinkCollector = FilteredElementCollector(doc, view.Id).OfClass(ImportInstance)  
cadLinks = cadLinkCollector.ToElements()

# code that modifies revit database goes here

for cad in cadLinks:  
viewSpecific = cad.ViewSpecific  
if viewSpecific and cad.Name == namsearch:  
ownerViewId = doc.GetElement( cad.OwnerViewId )  
else:  
ownerViewId = “Not working properly”

OUT = ownerViewId

[FINDING LOST CAD BY NAME.dyn](https://forum.dynamobim.com/uploads/short-url/e76GddjkNwoU46r0CnQU2QesjUp.dyn) (5.1 KB)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [March 13, 2018, 8:54pm UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/5 "2018-03-13T20:54:29Z")

</div>

Try BimorphNodes CAD.ReportInstances node

---

<div class="post-metadata">

**Author:** ![simon\_murphy1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/simon_murphy1/32/101536_2.png) [@simon\_murphy1](https://forum.dynamobim.com/u/simon_murphy1)\
**Post date:** [March 14, 2018, 9:02am UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/6 "2018-03-14T09:02:50Z")

</div>

Thanks for the tip but was mainly using it has a problem to practice python.

Now got one that works the way I wanted.

[FINDING LOST CAD FINAL MARCH2018.dyn](https://forum.dynamobim.com/uploads/short-url/9P1tUyzZRIJ13x2Krqdafy934wX.dyn) (8.3 KB)

---

<div class="post-metadata">

**Author:** ![Thom\_Krejci](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@Thom\_Krejci](https://forum.dynamobim.com/u/Thom_Krejci)\
**Post date:** [August 7, 2018, 9:30pm UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/7 "2018-08-07T21:30:16Z")

</div>

This has been a great help to me. Unfortunately, this no longer works in 2018 (at least for me). Something with the Python code isn’t producing the same output as before.

I’ve updated the parameter names as required but I keep getting a null from the Python Script.

[Find Lost CAD Inserts v0.1.dyn](https://forum.dynamobim.com/uploads/short-url/7r54USOLzXKyPbHo5JDDYneuEfi) (44.9 KB)

Here’s the code: (I apologize that’s it’s formatted as indented text).

> import clr
> 
> # Import RevitAPI Classes
> 
> clr.AddReference(‘RevitAPI’)  
> from Autodesk.Revit.DB import \*  
> #the above can be changed to import just specific classes separated by a comma
> 
> clr.AddReference(‘ProtoGeometry’)  
> from Autodesk.DesignScript.Geometry import \*
> 
> clr.AddReference(‘RevitNodes’)  
> import Revit
> 
> # Adds ToDSType (bool) extension method to wrapped elements
> 
> clr.ImportExtensions(Revit.Elements)  
> #adds ToProtoType, ToRevitType geometry conversion extension methods to objects  
> clr.ImportExtensions(Revit.GeometryConversion)
> 
> #import documentmanager and transaction manager  
> clr.AddReference(‘RevitServices’)  
> from RevitServices.Transactions import TransactionManager  
> from RevitServices.Persistence import DocumentManager
> 
> # create varible for revit document
> 
> doc = DocumentManager.Instance.CurrentDBDocument  
> elements = UnwrapElement(IN[0])  
> nams =
> 
> # start transaction
> 
> TransactionManager.Instance.EnsureInTransaction(doc)
> 
> # code that modifies revit database goes here
> 
> for ele in elements:
> 
> #end transaction  
> TransactionManager.Instance.TransactionTaskDone()
> 
> OUT = nams

Thanks again!

---

<div class="post-metadata">

**Author:** ![Ning\_Zhou](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ning_zhou/32/68283_2.png) [@Ning\_Zhou](https://forum.dynamobim.com/u/Ning_Zhou)\
**Post date:** [December 18, 2018, 9:08pm UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/8 "2018-12-18T21:08:43Z")

</div>

is it doable to change OwnerViewId i.e. “rehost” imported DWG to another view, seems manually cut/paste trick doesn’t work

---

<div class="post-metadata">

**Author:** ![simon\_murphy1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/simon_murphy1/32/101536_2.png) [@simon\_murphy1](https://forum.dynamobim.com/u/simon_murphy1)\
**Post date:** [March 12, 2020, 10:06am UTC](https://forum.dynamobim.com/t/find-cad-link-referencing-view/7204/9 "2020-03-12T10:06:18Z")

</div>

SHARE

Select the correct index for your CAD link.

[cad link location.dyn](https://forum.dynamobim.com/uploads/short-url/lhgdFFYCEWhaYeB7uGkVGIbWfp9.dyn) (8.8 KB)
