Export Sheets from Linked Models

I am wondering if it is possible to export sheets (or views) from linked models?

I am currently running a graph that works for a Revit File, and can export the sheets in the project. I have tried to link up the Archi-lab nodes for getting elements from linked files, which lists all of the sheets in the linked file…it is just the next step to get it to export the sheets…am I asking too much???

Current graph attached…

Sheets to DWG from Linked.dyn (12.5 KB)

Hi Scott,

I was wondering if you ever completed this script? I would be keen to know as I am looking to put something like this into place myself.

Thanks,

Tom

I put it on hold, but have started to have a look at it again…if I make any advancements I will post the results.

2 Likes

Hi @Scott_Crichton ,

export in pdf?

Yes, I currently have a script that will print pdf’s from a file and then renames them all to meet our document Management system. The next step is to get this to automatically run on multiple files…

I thought it might be a good start to see if it will get all of the linked models and print the pdf’s that are also in those files (as long as the View Sets are named the same)…

The end goal is just to select a list of Revit models and then print all of the sheets in each model from the View Sets…

Hi @Scott_Crichton

@john_pierson Rhythm Document.BackgroundOpen will get you started i think. You can then extract sheets sets from the revit model.

@Scott_Crichton ,

yes using Document.BackgroundOpen as @Kulkul says is useful, but it’s not enough to complete your task.
You must modify @Konrad_K_Sobon 's print pdf node a little bit :

change the line :

doc = DocumentManager.Instance.CurrentDBDocument

to

doc = IN[7]


then add an extra input to the python node and feed it the document. I just tried and it works well !

8 Likes

Thanks guys, this looks like it will solve my queries. I won’t get a chance to adjust it for a couple of days but I am excited to see the results.

3 Likes

Hi,

your solution doens’t seem to work on central models. i get a traceback:File “”, line 68, in
Exception: Attempt to modify the model outside of transaction.

I need it to work on central models because we (at the firm i work for) only link central models into each other not locals.
also I cant input multiple revit documents.

i’m trying to implement printing from linked models into my pdf printing graph, and i used your code as a proof of concept.

any ideas about how i could make it work?

Can you post your graph please. Tnx

as i said, i used the same graph as @Mostafa_El_Ayoubi

hi @timhevel ,
sorry for the late reply. Did you figure it out or do you still need that issue to be adressed?

Hi @Mostafa_El_Ayoubi

No unfurtunately i didn’t find a solution yet.

have you been able to input multiple linked central models?

I don’t think central models should be an issue. In order to input lists of documents, you’d need to either

  • alter the print pdf node’s code a bit more
  • create a custom node and use list@level feature (less coding needed).

I’ll give it a try and let you know how it goes.

I’m new to Dynamo so maybe I’m missing something basic.

I was able to follow along with @Mostafa_El_Ayoubi 's bit above (dated Feb 15) and it prints all sheets from a single designated file. I can’t for the life of me figure out how to have it pull multiple files and print all sheets from all files. I can specify ONE specific file and print all sheets but not multiple files. I need to to be able to print all sheets from upwards of twenty documents at a time. All twenty files, plus others I don’t want printed, are linked into an overall combined model, but I can’t get the list of linked models to translate down to the print.

I’d share my screen capture, but I’ve tried so many different options that don’t work and nothing that even comes close to working. I am using Dynamo 1.3.2 and have Archi Lab and Rhythm packages installed but don’t really want to install too many custom nodes since quite a few people will end up running this script.

Thanks for the help gents.

Hi Tim,

I change a little bit the script of K Sobon and I can now input a list of documents :

#Copyright(c) 2015, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
# Revised by viktor_kuzev
# Revised by Alban de Chasteigner

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = IN[7]
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

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

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

sheets = IN[0]
pRange = System.Enum.Parse(Autodesk.Revit.DB.PrintRange, IN[1])
combined = IN[2]
printerName = IN[3]
printSettings = IN[4]
filePath = IN[5]
runIt = IN[6]

if isinstance(sheets, list):
	viewSheets = []
	for i in sheets:
		viewSheets.append(UnwrapElement(i))
else:
	viewSheets = UnwrapElement(sheets)

if isinstance(printSettings, list):
	printSetting = []
	for i in printSettings:
		printSetting.append(UnwrapElement(i))
else:
	printSetting = UnwrapElement(printSettings)
	
t = Transaction(doc,'export')
t.Start()
printManager = doc.PrintManager		
printSetup = printManager.PrintSetup
printManager.SelectNewPrintDriver(printerName)
if isinstance(printSettings, list):
	printSetup.CurrentPrintSetting = printSetting[0]
else:
	printSetup.CurrentPrintSetting = printSetting
printManager.Apply()
t.Commit()

def PrintView(doc, sheet, pRange, printerName, combined, filePath, printSetting):
	# create view set 
	viewSet = ViewSet()
	if isinstance(sheet, list):
		for s in sheet:
			viewSet.Insert(s)
	else:
		viewSet.Insert(sheet)
	# determine print range
	printManager = doc.PrintManager
	printManager.PrintRange = pRange
	printManager.Apply()
	# make new view set current
	viewSheetSetting = printManager.ViewSheetSetting
	viewSheetSetting.CurrentViewSheetSet.Views = viewSet
	# set printer
	printManager.SelectNewPrintDriver(printerName)
	printManager.Apply()
	# set combined and print to file
	if printManager.IsVirtual:
		printManager.CombinedFile = combined
		printManager.Apply()
		printManager.PrintToFile = True
		printManager.Apply()
	else:
		printManager.CombinedFile = combined
		printManager.Apply()
		printManager.PrintToFile = False
		printManager.Apply()
	# set file path
	printManager.PrintToFileName = filePath
	printManager.Apply()
	# apply print setting
	try:
		printSetup = printManager.PrintSetup
		printSetup.CurrentPrintSetting = printSetting
		printManager.Apply()
		
	except:
		pass
	# save settings and submit print
	t.Start()
	viewSheetSetting.SaveAs("tempSetName")
	printManager.Apply()
	printManager.SubmitPrint()
	viewSheetSetting.Delete()
	t.Commit()
	
	return True

try:
	viewSets = FilteredElementCollector(doc).OfClass(ViewSheetSet)
	for i in viewSets:
		if i.Name == "tempSetName":
			TransactionManager.Instance.EnsureInTransaction(doc)
			doc.Delete(i.Id)
			TransactionManager.Instance.ForceCloseTransaction()
		else:
			continue
		
	errorReport = None
	message = "Success"
	if runIt:
		if isinstance(viewSheets, list) and isinstance(printSetting, list):
			for i, j in zip(viewSheets, printSetting):
				PrintView(doc, i, pRange, printerName, combined, filePath, j)
		elif isinstance(viewSheets, list) and not isinstance(printSetting, list) and combined == True:
			PrintView(doc, viewSheets, pRange, printerName, combined, filePath, printSetting)
		elif isinstance(viewSheets, list) and not isinstance(printSetting, list):
			for i in viewSheets:
				PrintView(doc, i, pRange, printerName, combined, filePath, printSetting)
		elif not isinstance(viewSheets, list) and not isinstance(printSetting, list):
			PrintView(doc, viewSheets, pRange, printerName, combined, filePath, printSetting)
	else:
		message = "Set RunIt to True"
except:
	# if error accurs anywhere in the process catch it
	import traceback
	errorReport = traceback.format_exc()
	
#Assign your output to the OUT variable
if errorReport == None:
	OUT = message
else:
	OUT = errorReport

You also need to collect the Printsettings from the revit documents.
With a custom node and lacing, it will work well.

1 Like

Hi Tim,

I find this script very interesting and have try to input a list of documents, but it keep

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 63, in
TypeError: expected Document, got list

Hi,

For a list of documents, you must create a custom node and use lacing (longest).
You can use the package “Genius Loci” and the node “Print PDF from directory”.

Thanks,

Is there a node or script that collect the Printsettings from Link documents?

If I understand well your question, the node “Printsettings from document” from same package should suit your needs.