Export dwg saved set and then reload imported cad files

I am looking for some insight on whether something is possible.

A workflow we have in the office is as follows for different apartment layouts:

-We create the wall/door/window layout in revit
-We put each of these layouts in it’s own view
-We save these views when doing an export to dwg
-We import the dwgs and use these in our drawings

I am wondering if it would be possible to create a script that would:

  1. Export the saved dwg list of views which would overwrite the existing dwgs
  2. Then reload the overwritten dwg files.



@kslifter a bit late, but worth checking, hope it helps:

import clr
import Revit
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
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'
doc = DocumentManager.Instance.CurrentDBDocument
folderPath = IN[0]
if isinstance(IN[1], list) : fileNames = IN[1]
else : fileNames = [IN[1]]
allViews = FilteredElementCollector(doc).OfClass(View)
viewsD = {}
views = []
for view in allViews:
	if not view.IsTemplate:
		viewsD[view.Name] = view
for name in fileNames:
	for key in viewsD.keys():
		if key == name:
refresh = IN[2]
cadLinks = []
dwgOptions = DWGExportOptions()
for view, f in zip(views, fileNames):
	viewsE = List[ElementId]()
	doc.Export(folderPath, f, viewsE, dwgOptions)	
cads = FilteredElementCollector(doc).OfClass(ImportInstance)
if refresh == True or refresh == False:
	for cad in cads:
		if cad.Category.Name.EndsWith(".dwg"):
			typeId = cad.GetTypeId()
			cadLink = doc.GetElement(typeId)
OUT = cadLinks
1 Like

Wow, thanks! I’ll try it out!

I am not necessarily new to Dynamo, but still not very proficient in it. I haven’t really dived into Python Scripts at all. How do I go about inputting the script into the node?

@kslifter just copy/ paste the script content onto a Python Script node

1 Like

I got this error code. What is the workflow when using this script?

@kslifter you need to have the dwg files already linked in the Revit file, and you have to Browse to the folder the dwg files are found at using the Directory Path node.
when you want to mention someone please use the “@” character.