<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PrintDriver and PrintRange are overidden by Revit in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/printdriver-and-printrange-are-overidden-by-revit/m-p/6843458#M60613</link>
    <description>&lt;P&gt;Yes is have read that post,&lt;/P&gt;&lt;P&gt;it is a different problem but it might have the same cause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't contacted him yet, but by tagging him I hoped that he would see the post.&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2017 15:18:04 GMT</pubDate>
    <dc:creator>TimHevel</dc:creator>
    <dc:date>2017-01-31T15:18:04Z</dc:date>
    <item>
      <title>PrintDriver and PrintRange are overidden by Revit</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/printdriver-and-printrange-are-overidden-by-revit/m-p/6842747#M60611</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm currently trying to adapt&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2113574"&gt;@sobon.konrad&lt;/a&gt;&amp;nbsp;PDF Print dynamo node to fit the needs of the firm&amp;nbsp;I work for.&lt;/P&gt;&lt;P&gt;I have already managed to adapt it so that I can feed in a list of printsettings (with code provided by&amp;nbsp;Viktor Kuzev of the DynamoBIM forum)&lt;/P&gt;&lt;P&gt;But I have ran into a problem. The code seems to ignore the printdriver and the printrange I feed in. Instead it uses the printdriver and print range secified in Revit. At least it seems like it compares the setup&amp;nbsp;in the script to the printsetup in Revit, and when it doesn't match it won't run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I specify the right setup&amp;nbsp;in Revit it runs fine. (in my case: "Bullzip PDF Printer" and Select)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I'm trying to implement it in the firm I work for, I want it to work without having&amp;nbsp;to rely on everyone in the firm remembering to change the setup before they print.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope anyone can help me,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tim Hevel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#Copyright(c) 2015, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

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 = DocumentManager.Instance.CurrentDBDocument
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)
	
TransactionManager.Instance.EnsureInTransaction(doc)
printManager = doc.PrintManager		
printSetup = printManager.PrintSetup
if isinstance(printSettings, list):
	printSetup.CurrentPrintSetting = printSetting[0]
else:
	printSetup.CurrentPrintSetting = printSetting
printManager.Apply()
TransactionManager.Instance.TransactionTaskDone()

def PrintView(doc, sheet, pRange, printerName, combined, filePath, printSetting):
	# create view set 
	viewSet = ViewSet()
	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
	TransactionManager.Instance.EnsureInTransaction(doc)
	viewSheetSetting.SaveAs("tempSetName")
	printManager.Apply()
	printManager.SubmitPrint()
	viewSheetSetting.Delete()
	TransactionManager.Instance.TransactionTaskDone()
	
	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):
			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&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 09:41:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/printdriver-and-printrange-are-overidden-by-revit/m-p/6842747#M60611</guid>
      <dc:creator>TimHevel</dc:creator>
      <dc:date>2017-01-31T09:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: PrintDriver and PrintRange are overidden by Revit</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/printdriver-and-printrange-are-overidden-by-revit/m-p/6843426#M60612</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Tim,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your query.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Have you read this thread by Konrad Sobon himself, discovering that a similar problem that arose in his use case was due to the printer driver?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/printing-api-and-printmanager-printtofilename-setting/td-p/5700058" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/printing-api-and-printmanager-printtofilename-setting/td-p/5700058&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If so, and the problem persists, have you tried contacting Konrad directly to find out how he handles this?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;After all, he has left his contact details in the code, so I would assume he might be willing to help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:09:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/printdriver-and-printrange-are-overidden-by-revit/m-p/6843426#M60612</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-31T15:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: PrintDriver and PrintRange are overidden by Revit</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/printdriver-and-printrange-are-overidden-by-revit/m-p/6843458#M60613</link>
      <description>&lt;P&gt;Yes is have read that post,&lt;/P&gt;&lt;P&gt;it is a different problem but it might have the same cause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't contacted him yet, but by tagging him I hoped that he would see the post.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 15:18:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/printdriver-and-printrange-are-overidden-by-revit/m-p/6843458#M60613</guid>
      <dc:creator>TimHevel</dc:creator>
      <dc:date>2017-01-31T15:18:04Z</dc:date>
    </item>
  </channel>
</rss>

