I am trying to use the Export to PDF to create combined PDF files with Assembly Name as the .pdf name for the Sheets within an Assembly list.
I have done this with
-creating temporary individual .pdf per sheet
-then combining with later with Merge.MergePDF’s
-then deleting the temporary individual .pdf once files are merged.
I would like to use Python to eliminate the secondary task of combining/merging .pdf files. I believe this would cut my processing time in half.
I have found the options that are within the Revit API, but looking for some help to get my to the finish line. I am fairly green in Python.
import clr
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument
# Define list/unwrap list functions
def tolist(input):
result = input if isinstance(input, list) else [input]
return result
def uwlist(input):
result = input if isinstance(input, list) else [input]
return UnwrapElement(input)
# Preparing input from dynamo to revit
sheets = uwlist(IN[0])
names = IN[1]
direc = IN[2]
options = IN[3]
#Sean Page, 2021
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
# Current document
doc = DocumentManager.Instance.CurrentDBDocument
# Collect inputs and set containers
Sheets = UnwrapElement(IN[0])
Names = IN[1]
Folder = IN[2]
Options = IN[3]
result = []
sheets = List[ElementId]()
# Collect and set export options
opts = PDFExportOptions()
opts.HideCropBoundaries = 1
opts.HideScopeBoxes = 1
opts.HideReferencePlane = 1
opts.HideUnreferencedViewTags = 1
opts.MaskCoincidentLines = 1
opts.Combine = 1
opts.FileName = names
opts.ColorDepth = ColorDepthType.GrayScale
# This will uses the Sheet Size for Paper size, or default to Letter
opts.PaperFormat = ExportPaperFormat.Default
# Execute the batch export
for sheet,name in zip(Sheets,Names):
opts.FileName = names
Sheet = List[ElementId]()
Sheet.Add(sheet.Id)
result.append(doc.Export(Folder,Sheet,opts))
# Preparing output to Dynamo
OUT = result