Export dwg setup

Hello community,
Do you know if there is any way to export layers setup to excel using dynamo or any other app???

Any help on this one???

Yes you can get that information with Python from the ExportDWGSettings

The workflow would be to

  1. Collect ExportDWGSettings (could be done with All Elements of Type in Dynamo, or within the Python script).
  2. From the ExportDWGSettings element, use the method GetDWGExportOptions().
  3. Use the method GetExportLayerTable(). Once you have the ExportLayerTable, you can use the methods GetKeys() and GetValues().
  4. From GetKeys you will get ExportLayerKeys which will supply you the properties Category and Subcategory, and from GetValues() you will be supplied ExportLayerInfo which will provide you the category type (i.e. model, annotation, etc) and the layer information (color, layer name, etc)
  5. Export to Excel
1 Like

Hello Amy,
Thank you vey much for your help.
I quite new in Dynamo, you mean all of it can be done without the need of python?

No I don’t believe this can be done with Dynamo alone - what I described above was the workflow you can follow using Python and the Revit API - can’t hurt to give it a first try :slight_smile: when I was learning Python for Revit I would examine the Python scripts that others have written to make sense of it

Thanks Amy, I am going to try…

@BIMadmin Here is a working Python script to get the information on the Layers tab in the Modify DWG/DXF Export Setup window:

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument

settings = IN[0]
if not isinstance(settings,list):
	settings = [settings]

def getExportInfo(set):
	cattype = []
	category = []
	subcategory = []
	colorname = []
	colornumber = []
	cutcolornumber = []
	cutlayername = []
	layername = []
	options = set.GetDWGExportOptions()
	table = options.GetExportLayerTable()
	keys = table.GetKeys()
	for key in keys:
		category.append(key.CategoryName)
		subcategory.append(key.SubCategoryName)
	layerinfo = table.GetValues()
	for i in layerinfo:
		cattype.append(i.CategoryType)
		colorname.append(i.ColorName)
		colornumber.append(i.ColorNumber)
		cutcolornumber.append(i.CutColorNumber)
		cutlayername.append(i.CutLayerName)
		layername.append(i.LayerName)
	return zip(cattype,category,subcategory,layername,colorname,colornumber,cutlayername,cutcolornumber)

exportSettings = [getExportInfo(UnwrapElement(i)) for i in settings]

OUT = exportSettings

You’ll notice this output is not sorted by Category Type or Category so you’ll want to do some post processing (either in Dynamo, which I’d recommend for practice, or in Excel when you’ve exported it).

To get the information from the Lines and Patterns tab, you’d follow a similar workflow with the relevant API methods. This script is a bit more complex because it is made to work for a single DWGExportSettings element or a list; I hope it helps!

3 Likes

Thank you very much for your support Amy!!!
You make a difference!!! I hope I can get my hands into python but probably this is too much as a start!!!
thanks again!!!

Hello, I follow this method to collect the all layer category.

However, I want to more specific to get the Id from each category, is it possible?

I tried to utilize the " ExportLayerTableIterator Class", but my program skill just from the beginner. Could any one can help for this question?

@Chiang_ShuoTao Please start a new topic.

@awilliams I have a question? If you respect the view template.

Regards