Linked DWG from current view to Grasshopper with Layers and Geometry

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 (5.1 MB)
Any help is appreciated.

0_SimplifiedCAD.dwg (65.9 KB)

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

GetCADData.gh (13.2 KB) [Updated 6/28/2021]
GetLayersFromCADInstance.3dm (111.4 KB)
Linked DWG.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 :smiley:

3 Likes

Thanks @eirannejad , I will try it out.

1 Like

Hey @eirannejad,

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

Thanks for helping.:pray:

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,

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.