Export to DXF

Is there a node that allows you to export a view as a dxf?

I never tried it but if you speak python you could look here to write your own:
http://www.revitapidocs.com/2018.1/fd65887a-3d13-3ff1-ec95-7c0379317c85.htm
http://www.revitapidocs.com/2018.1/00783eca-208f-cc58-d56f-b47814a6957a.htm
https://msdn.microsoft.com/en-us/library/92t2ye13

Also check this post for analogy

2 Likes

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

Thank you so much for your solution! I made it succeed to batch export file in DWG, DXF and SAT, but not make it for the DGN format. Have you tried this format? Do you know why this is not working for DGN format?

Here is the code i am using for the DGN format export:

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 _ExportDGN(xfolder, xview):
	options = DGNExportOptions()
	views = List[ElementId]()
	id=ElementId(xview.Id)
	views.Add(id)
	xname="Export-" + xview.Name + ".DGN"
	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 DGNs failed"

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

OUT=rtn

Where is DOC declared?

Edit: just seen it. Global parameters in Python :-1: IMO

Try exporting a simple element like a line to DWG. If that works, try DGN. If it fails, troubleshoot from there.

Thank you so much for your response Thomas!

Yes. I have tried adding just a single line in a view in a brand new project file. Then tried to export by using the same Python script structure except for using different “options” and file extension. DWG, DXF and SAT are all working, except for DGN.

I am not really familiar with the DGN format. Is there anything need to be set prior to the exporting the DGN?

Hello, I am trying to export dxf file .
Dxf is the created but it gives to options in dialog “Export with temporary hide/ isolate”…
Can anyone know what how can I set anyone of the option through dynamo.

Here is the dialogue box.