# Linked DWG from current view to Grasshopper with Layers and Geometry

**URL:** <https://discourse.mcneel.com/t/linked-dwg-from-current-view-to-grasshopper-with-layers-and-geometry/125504>\
**Category:** Revit\
**Tags:** windows\
**Created:** [June 7, 2021, 9:55am UTC](https://discourse.mcneel.com/t/linked-dwg-from-current-view-to-grasshopper-with-layers-and-geometry/125504 "2021-06-07T09:55:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mucahitbgoker](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mucahitbgoker/32/500249_2.png) [@mucahitbgoker](https://discourse.mcneel.com/u/mucahitbgoker)\
**Post date:** [June 7, 2021, 9:55am UTC](https://discourse.mcneel.com/t/linked-dwg-from-current-view-to-grasshopper-with-layers-and-geometry/125504/1 "2021-06-07T09:55:13Z")

</div>

Hey guys,

I have linked dwg file in my Level 1 view. Its only visible in this view. I want to get its layers, curves etc. and use them to create floors. I have tried to select it using “Graphical Element” but it gets it location i believe. I have tried importing CAD file into Rhino directly but aligning it becomes a hassle. Any idea how can i get linked DWGs with layer names and geometries into Grasshopper?

I have attached a sample Revit 2021 file. DWG is also attached.  
[Linked DWG.rvt](https://discourse.mcneel.com/uploads/short-url/ra8qcg9BHwrRRyLhayvwJ8D2vV0.rvt) (5.1 MB)  
Any help is appreciated.

[0\_SimplifiedCAD.dwg](https://discourse.mcneel.com/uploads/short-url/hBU7GrrSNLKCC7b528Qt3v5bs59.dwg) (65.9 KB)

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [June 15, 2021, 9:12pm UTC](https://discourse.mcneel.com/t/linked-dwg-from-current-view-to-grasshopper-with-layers-and-geometry/125504/2 "2021-06-15T21:12:15Z")

</div>

@mucahitbgoker

**Problem**

- Revit API does not have anything specific to pull DWG information from imports.

**Workaround 1**

- See the Grasshopper definition attached. This definition has a set of custom python components that grab the geometry from the imported DWG element (DB.ImportInstance)
- The extracted lines returned by Revit API as geometry, have a DB.GraphicsStyle applied to them. This style has some of the info about the layer that the line was extracted from
- We can use this information to bake the lines in specific layers in Rhino. For this I’m using the Bake component from _LunchBox_ GH addon, but other similar solutions are available in _Elefront_, _Human_, and _Pancake_ I believe.

 ![Screen Shot 2021-06-15 at 2.04.18 PM](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/5/5/9558f53b380607d681d2acd7fced1c274f26c62c.png)

 ![Screen Shot 2021-06-15 at 2.03.41 PM](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/6/4/5/645e5ed5fe6bc47f00502386ffbd1c32cc43556c.png)

[GetCADData.gh](https://discourse.mcneel.com/uploads/short-url/hFiBMHwlcinOlYRcGDhyrjQ9yyI.gh) (13.2 KB) [Updated 6/28/2021]  
[GetLayersFromCADInstance.3dm](https://discourse.mcneel.com/uploads/short-url/lIyabHh9GdtSnLiXGGFq4YbryHO.3dm) (111.4 KB)  
[Linked DWG.rvt](https://discourse.mcneel.com/uploads/short-url/q8vGFJzuDVKXKNQyXpTXezeKDHa.rvt) (5.2 MB)

**Workaround 2**

- The same grasshoppe definition above, shows a method to extract the path of the linked DWG file. This can be imported in Rhino and processed. I believe _Pancake_ addon can help here.

Hope this helps putting you on the right track 😃

---

<div class="post-metadata">

**Author:** ![mucahitbgoker](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mucahitbgoker/32/500249_2.png) [@mucahitbgoker](https://discourse.mcneel.com/u/mucahitbgoker)\
**Post date:** [June 16, 2021, 6:09am UTC](https://discourse.mcneel.com/t/linked-dwg-from-current-view-to-grasshopper-with-layers-and-geometry/125504/3 "2021-06-16T06:09:11Z")

</div>

Thanks @eirannejad , I will try it out.

---

<div class="post-metadata">

**Author:** ![mucahitbgoker](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mucahitbgoker/32/500249_2.png) [@mucahitbgoker](https://discourse.mcneel.com/u/mucahitbgoker)\
**Post date:** [June 20, 2021, 6:17pm UTC](https://discourse.mcneel.com/t/linked-dwg-from-current-view-to-grasshopper-with-layers-and-geometry/125504/4 "2021-06-20T18:17:50Z")

</div>

Hey @eirannejad,

Just tried it out the first method and it does just what i want it to do.

Thanks for helping.🙏

---

<div class="post-metadata">

**Author:** ![mucahitbgoker](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mucahitbgoker/32/500249_2.png) [@mucahitbgoker](https://discourse.mcneel.com/u/mucahitbgoker)\
**Post date:** [June 20, 2021, 6:28pm UTC](https://discourse.mcneel.com/t/linked-dwg-from-current-view-to-grasshopper-with-layers-and-geometry/125504/5 "2021-06-20T18:28:41Z")

</div>

When it comes to Workaround 2, I tried it on a new file with same CAD file attached, it gave the following error. Just so you know,

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/a/9/0a91ed0b3157070aea62bc031ae488616efde4c3.png)

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [June 28, 2021, 9:06pm UTC](https://discourse.mcneel.com/t/linked-dwg-from-current-view-to-grasshopper-with-layers-and-geometry/125504/6 "2021-06-28T21:06:45Z")

</div>

Sorry for the bug. I updated the uploaded GH definition. Make sure your Revit model is saved when runnig this script as Revit API needs that.
