# Exporting family istance to DWG singularly

**URL:** <https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473>\
**Category:** Revit\
**Tags:** python, dwg, dynamo, familyinstance, export\
**Created:** [December 10, 2024, 9:42am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473 "2024-12-10T09:42:42Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![l.canzian](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@l.canzian](https://forum.dynamobim.com/u/l.canzian)\
**Post date:** [December 10, 2024, 9:42am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/1 "2024-12-10T09:42:42Z")

</div>

Hi I am trying to export a family of revit to dwg like singular object files, I have like 30 variance and I need everyone of this in a singular DWG file.  
In another forum they helped me to create some nodes but I need that the objects stay on the origin and without this green lines. someone can help me?  
[familyDWGexport.dyn](https://forum.dynamobim.com/uploads/short-url/a1V3dQCrUhzjfxSNkrj3eSH5SQm.dyn) (36.9 KB)

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [December 12, 2024, 1:38am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/2 "2024-12-12T01:38:13Z")

</div>

Hi Leonardo, welcome 👋  
To change how the elements are exported can be controlled by visibility, so once you have created the views for export, change their settings.

So we can place all the elements at the origin, hide all others in each view. I’m assuming the green lines are the section box - so hide that category as well.

Python example code

```python
import clr
from System.Collections.Generic import List

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import BuiltInCategory, ElementId

elements = UnwrapElement(IN[0])
views = UnwrapElement(IN[1])

doc = DocumentManager.Instance.CurrentDBDocument

OUT = []

element_ids = [e.Id for e in elements]
sec_box_id = ElementId(BuiltInCategory.OST_SectionBox)

TransactionManager.Instance.EnsureInTransaction(doc)

for i, view in enumerate(views):
    ids = element_ids.copy()
    ids.pop(i)

    view.HideElements(List[ElementId](ids))
    view.SetCategoryHidden(sec_box_id, True)
    OUT.append(view)

TransactionManager.Instance.TransactionTaskDone()

```

 ![familyDWGexport](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/e/def059f034b6d60fdeb8215bbb6e1215586cdb3f.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/0/20965ac097ef68c9c2f056b242dcb75c26596838.png)

---

<div class="post-metadata">

**Author:** ![l.canzian](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@l.canzian](https://forum.dynamobim.com/u/l.canzian)\
**Post date:** [December 13, 2024, 9:27am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/3 "2024-12-13T09:27:14Z")

</div>

thank you, i would ask you about the code, a am not good with code and I inserted it in a python script but I have only one IN(0), you know why?

 ![Screenshot 2024-12-13 102451](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/d/9d91806bd11a6ea85aa214b0c90cbc3508a80538.png)

---

<div class="post-metadata">

**Author:** ![BimAmbit](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bimambit/32/192629_2.png) [@BimAmbit](https://forum.dynamobim.com/u/BimAmbit)\
**Post date:** [December 13, 2024, 10:32am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/4 "2024-12-13T10:32:38Z")

</div>

If you click on the plus sign, IN[1] will show up.

---

<div class="post-metadata">

**Author:** ![l.canzian](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@l.canzian](https://forum.dynamobim.com/u/l.canzian)\
**Post date:** [December 13, 2024, 12:41pm UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/5 "2024-12-13T12:41:19Z")

</div>

Thanks, it was easier than I thought.  
I have another problem with the visualization. I don’t want the layers of the project to be seen but when I set on the project the visibility and then I export with dynamo the views created have a different visibility type.  
Is there a way to set on dynamo the view setting to disable the annotation? or do you have some other suggestion?

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [December 13, 2024, 11:56pm UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/6 "2024-12-13T23:56:02Z")

</div>

To turn off all annotations in the view change the following line  
`view.SetCategoryHidden(sec_box_id, True)`  
to  
`view.AreAnnotationCategoriesHidden = True`

---

<div class="post-metadata">

**Author:** ![l.canzian](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@l.canzian](https://forum.dynamobim.com/u/l.canzian)\
**Post date:** [December 14, 2024, 9:00am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/7 "2024-12-14T09:00:04Z")

</div>

amazing, thank you.  
Last thing I promise: is there a way to set on code the color of exportation of the dwg model? now when I export the lines are red

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [December 15, 2024, 12:49am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/8 "2024-12-15T00:49:39Z")

</div>

Add a DWGExportOptions to the export node via the ExportSettings port.

You can change it with layers or linestyles

If you have a DWG export setting saved you could use something like this:  
Please note I am not at my workstation so I haven’t tested the code and there is probably already package nodes available  
The `IN[0]` is the name of your settings as a string and join the output to the ExportSettings

```python
import clr

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager 

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

doc = DocumentManager.Instance.CurrentDBDocument

# Edited
options = ExportDWGSettings.FindByName(doc, IN[0])
# ignore: options.GetPredefinedOptions(doc, IN[0])

OUT = options

```

---

<div class="post-metadata">

**Author:** ![l.canzian](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@l.canzian](https://forum.dynamobim.com/u/l.canzian)\
**Post date:** [December 16, 2024, 8:46am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/9 "2024-12-16T08:46:38Z")

</div>

ok, I am in this situation, I put the code in the export setup but I didn’t understand how I could decide the color of my line. I want the lines to be all black in the dwg model. I’m sorry but I’m not good at all with programming and using Dynamo, it’s the first time 😅

 ![Screenshot 2024-12-16 094137](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/6/d60932f4e6b810c8630af94235b2b9ce2e676de3.png)

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [December 16, 2024, 11:30am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/10 "2024-12-16T11:30:52Z")

</div>

Review [this section](https://help.autodesk.com/view/RVT/2024/ENU/?guid=GUID-42C75024-4D71-4831-8910-2747168624A3) of the Revit support site on export setups - create the export settings that you want and load them in. Genius Loci have a _Create DWG Export Setup_ node

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

---

<div class="post-metadata">

**Author:** ![l.canzian](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@l.canzian](https://forum.dynamobim.com/u/l.canzian)\
**Post date:** [December 17, 2024, 9:48pm UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/11 "2024-12-17T21:48:37Z")

</div>

Ok, i don’t know what my problem is but it’s like if the node create dwg export setup don’t read my DWG setting because, when I export it doesn’t change the color of lines and the name of the layer where the family as you can see. Do you have any idea?

 ![Screenshot 2024-12-17 223428](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/a/cacd50262c5a682fb2b552e17a64f522b83ca25a.png)  
 ![Screenshot 2024-12-17 223435](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/3/f3d2c8fc4aec4ede13afd39ff7e42b2d4efac2cd.png)

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [December 18, 2024, 1:47am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/12 "2024-12-18T01:47:20Z")

</div>

Ok, lets run through this  
I am using a Furniture family and ISO standard layers - Layer colour is 30

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/d/ad6190d6ce9089bb74b31150dcd2194b6702ed97.png)  
Our export shows up in the DWG like this  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/4/c4418d090e98290f1a3e8cc2587be06968d09a1e.png)  
Change the colour  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/c/2c4c604459fbc181aed16f9740e13c8cb9229b90.png)  
Aaaand the Genius Loci Nodes do not work…  
OK back to the drawing board  
Swap to Crumple nodes _Revit.ExportToDwg_ and _Revit.ExportOptionsDwg_. Use the settings name and…  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/4/c4d1c7048be6f58e50d9d36fc9b9efb14c108f1f.png)  
It works!  
 ![familyDWGexport_update](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/5/057b8ab4b18a2feb5142bcb313317f24b778bbe2.png)

I have also added the option to delete the families and views so you can do this in place. Dyn file and code below

```python
from itertools import chain
from System.Collections.Generic import List
import clr

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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

def id(element):
    return element.Id

families = map(id, UnwrapElement(IN[1]))
views = map(id, UnwrapElement(IN[2]))

doc = DocumentManager.Instance.CurrentDBDocument

TransactionManager.Instance.EnsureInTransaction(doc)

if IN[0]:
    deleted_ids = doc.Delete(List[ElementId](chain(families, views)))

TransactionManager.Instance.TransactionTaskDone()

OUT = deleted_ids

```

[familyDWGexport.dyn](https://forum.dynamobim.com/uploads/short-url/4uNgyxDmrhThXhuZVetnJqyNctb.dyn) (39.8 KB)

---

<div class="post-metadata">

**Author:** ![l.canzian](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@l.canzian](https://forum.dynamobim.com/u/l.canzian)\
**Post date:** [December 18, 2024, 8:54am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/13 "2024-12-18T08:54:02Z")

</div>

Ok, i think something is missing because the python script gave me this two errore, i tried in revit 2022 and 2024 for check

 ![Screenshot 2024-12-18 alle 09.51.20](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/6/36dc7bb1619d24bac7713b4c8fa1ab9e5589867e.jpeg)  
 ![Screenshot 2024-12-18 alle 09.51.31](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/4/14428c53ff3311724d7604af09d110190f62b0cf.jpeg)

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [December 20, 2024, 8:05am UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/14 "2024-12-20T08:05:34Z")

</div>

It’s hard to tell without knowing your inputs, can you pin the results of the nodes before the errors and export the full graph.

I would also start with a empty project file and only add the family you want to export, set up your preferred export settings and then run the script.

The first node expects the family instances of each type and its associated view - so I don’t know how it is getting a text value unless I see the nodes before. Does your family only have one type? The python nodes are coded to operate on lists

---

<div class="post-metadata">

**Author:** ![l.canzian](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@l.canzian](https://forum.dynamobim.com/u/l.canzian)\
**Post date:** [December 29, 2024, 8:37pm UTC](https://forum.dynamobim.com/t/exporting-family-istance-to-dwg-singularly/106473/15 "2024-12-29T20:37:07Z")

</div>

ok, for some reason everything works perfectly now, thank you very much for the great help you gave me, you were really kind, thanks again 🙂
