Export to DXF

If you download the package Chynamo, there is a node View.ExportDWG with a Python script within it; that Python script could be modified easily using the second API reference @GregX provided you… looks like you would only really need to change 2 lines for it to export DXF :slight_smile:

Here is the code within that node, I still recommend downloading that package anyway (lots of useful nodes, plus you can see how the View.ExportDWG nodes inputs work):

import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import System
from System.Collections.Generic import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

def _ExportDwg(xfolder, xview):
	options = DWGExportOptions()
	views = List[ElementId]()
	id=ElementId(xview.Id)
	views.Add(id)
	xname="Export-" + xview.Name + ".DWG"
	try:
		rtn = DOC.Export(xfolder, xname, views, options)
	except: 
		rtn=None
	return rtn

XFOLDER = IN[1]
XVIEW = IN[2]
DOC = DocumentManager.Instance.CurrentDBDocument
rtn = "Export DWGs failed"

if IN[0] == True:
	for abc in XVIEW:
		try:
			rtn = _ExportDwg(XFOLDER, abc)
			rtn = "Export DWGs successful"
		except:
			rtn = "Export DWGs failed"

OUT=rtn
5 Likes