Hello Dynamo Friends
I would like to know how i can create a print setting in python.
Orchid does it with the Print.CreateSetting node.
In addition i want to know which of these options i can control when creating the setting, or which of them i can adjust after the setting is created.
Happy about any advice
Kind regards!
So there is the PrintSetting Class that can control all these Print Setting options.
Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018
And it seems that i will need the Print Manager.
Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018
Here some code snippets i googled together…maybe i will not create a Print Setting, but just stay in the “in session” setting and make my adjustments?!
# Set print range
printManager = doc.PrintManager
printManager.PrintRange = printManager.PrintRange.Select
printManager.Apply()
# Define current view set as current
viewSet = ViewSet()
viewSet.Insert(sheet)
viewSheetSetting = printManager.ViewSheetSetting
viewSheetSetting.CurrentViewSheetSet.Views = viewSet
viewSheetSetting.SaveAs("Current Print")
# Set printer
printManager.SelectNewPrintDriver(printerName)
printManager.Apply()
# Print to file
printManager.CombinedFile = combined
printManager.Apply()
printManager.PrintToFile = True
printManager.Apply()
# Set destination filepath
printManager.PrintToFileName = filePath
printManager.Apply()
# Set print setting
printSetup = printManager.PrintSetup
printSetup.CurrentPrintSetting = pickPrintSetting(printSettingName)
printManager.Apply()
printManager = doc.PrintManager
printManager.PrintRange = PrintRange.Select
printManager.PrintToFile = True
viewSheetSetting = printManager.ViewSheetSetting
#setup print settings
printManager.ViewSheetSetting.CurrentViewSheetSet.Views = newViewSet
printManager.Apply()
printManager.PrintSetup.CurrentPrintSetting = printManager.PrintSetup.InSession
pParams = printManager.PrintSetup.CurrentPrintSetting.PrintParameters
for size in printManager.PaperSizes:
if size.Name == papersizes[i]:
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PaperSize = size
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ZoomType = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ZoomType.Zoom
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.Zoom = 100
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation.Landscape
printManager.PrintToFileName = fileLocation + fileName + ".pdf"
printManager.SelectNewPrintDriver(printerName)
printManager.PrintSetup.SaveAs(setupName)
printManager.Apply()
i += 1
printManager.CombinedFile = combineFiles
printManager.Apply()
printManager.SubmitPrint()
Is it by chance a archilab node? I can remember having some trouble getting that one to work myself so I wrote my own.
If you’re interested, see the code below.
I’m not sure if it exactly does what you want it to do, but it might help you find a solution to the problem.
I think that you should be able to make some small modifications to my code to have it so it takes a list of names and uses shortlacing to set the right name for your drawings. This would prevent having to rename them afterwar…
I think this is the line i was searching for:
printManager.PrintSetup.SaveAs(setupName)
So thats pretty much information to start testing.
Set up the code to adjust all available print setting options and save the print setting
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
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
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
sheet=UnwrapElement(IN[0])
printManager = doc.PrintManager
TransactionManager.Instance.EnsureInTransaction(doc)
for size in printManager.PaperSizes:
if size.Name == "A0":
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PaperSize = size
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ZoomType = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ZoomType.Zoom
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.Zoom = 100
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ZoomType = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ZoomType.FitToPage
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.HiddenLineViews = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.HiddenLineViews.VectorProcessing
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.HiddenLineViews = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.HiddenLineViews.RasterProcessing
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation.Landscape
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation.Portrait
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ViewLinksinBlue = True
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.HideReforWorkPlanes = True
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.HideUnreferencedViewTags = True
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.MaskCoincidentLines = True
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.HideScopeBoxes = True
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.HideCropBoundaries = True
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ReplaceHalftoneWithThinLines = True
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ColorDepth = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ColorDepth.Color
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ColorDepth = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ColorDepth.GrayScale
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ColorDepth = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ColorDepth.BlackLine
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.RasterQuality = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.RasterQuality.High
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.RasterQuality = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.RasterQuality.Low
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.RasterQuality = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.RasterQuality.Medium
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.RasterQuality = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.RasterQuality.Presentation
printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PaperPlacement = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PaperPlacement.Center
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PaperPlacement = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.PaperPlacement.LowerLeft
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.MarginType = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.MarginType.NoMargin
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.MarginType = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.MarginType.PrinterLimit
#printManager.PrintSetup.CurrentPrintSetting.PrintParameters.MarginType = printManager.PrintSetup.CurrentPrintSetting.PrintParameters.MarginType.UserDefined
printManager.PrintSetup.SaveAs("Test Setting")
printManager.Apply()
TransactionManager.Instance.TransactionTaskDone()
2 Likes
Hey Gerhard,
Question. Can you create a local print settings first, inject it into other Open Documents (Other files), and then use it to print?
AKA, Setup the Print Settings before printing to multiple files. I have been having issues as we received the following error:
Thanks so much boss.
Kevin
Hi, it worked for me but the printer configuration must be inside the document and if it doesn’t exist you will only have the default one, I would like to find a way to create the printer settings inside another document without having to enter the document.