Exporting family istance to DWG singularly

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 (36.9 KB)

Hi Leonardo, welcome :wave:
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

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()


2 Likes

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?

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

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?

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

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

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

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

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 :sweat_smile:

Review this section 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

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?


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


Our export shows up in the DWG like this

Change the colour
image
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…

It works!

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

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 (39.8 KB)

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