I want to a Add one more input Boolean(True/False) to the below python script, please helpout on these

import clr

clr.AddReference(‘System’)
from System.Collections.Generic import List

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager

Current doc/app/ui

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

Get revit version

revit_version = int(app.VersionNumber)

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(result)

Preparing input from dynamo to revit

directoryPath = IN[0]
sheets = uwlist(IN[1])
fileNames = tolist(IN[2])
options = IN[3]

If we are in Revit 2022 or higher, print

if revit_version > 2021:
# Import the references
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import PDFExportOptions, ElementId, ExportPaperFormat
# Collect and set export options
opts = PDFExportOptions()
opts.HideCropBoundaries = options[0]
opts.HideScopeBoxes = options[1]
opts.HideReferencePlane = options[2]
opts.HideUnreferencedViewTags = options[3]
opts.MaskCoincidentLines = options[4]
# This will uses the Sheet Size for Paper size, or default to Letter
opts.PaperFormat = ExportPaperFormat.Default
# Variables to append to
results =
sheetList = ListElementId
# Execute the batch export
for s, n in zip(sheets, fileNames):
# Set file name
opts.FileName = n
# Add sheet to a list
sheetList.Add(s.Id)
# Export and append the result
result = doc.Export(directoryPath, sheetList, opts)
results.append(result)
sheetList.Clear()
# Preparing output to Dynamo
OUT = results, “SUCCESS: Version is 2022 or higher.”

Otherwise tell the user we can’t proceed

else:
OUT = [False for s in sheets], “ERROR: Only works in Revit 2022 or higher.\n\nUse Revit.PrintToPdf node instead.”

![image|690x213](upload://iRcW0tYUaOBNU2YmVNDTGMecgXx.png)

what is holding you back in adding one more input?

Iam exporting both CAD & PDF , if i export CAD, pdf not exported so i need to add one more input of Boolean to the proceed that script or hold to play with true or false

Looks like you copied the contents of my print to pdf node in crumple and called it a day.

Need to show more effort to get assistance such as your script.

If you want to add more UI, look into data shapes package. If you want to add more Python functionality its time to learn Python I’d say - the forums aren’t chatGPT :wink:

4 Likes

Hi @GavinCrump exactly same i copied your script, and iam trying to add boolean for Export pdf node.

Thank your very much @GavinCrump your scripts helps a lot.

You could try a if node so you can control what to run

If they do this in Python they could do it in this manner.

@ramsaik495 go look at my add/remove revisions and there runMe input for an example of introducing conditional logic to running.

If you know Python this should be easy enough to emulate.

Thanks @sovitek i am applyed if node that’s works perfectly

yes @GavinCrump i saw your scripts amazing more helpful, keep growing thanks a lot…,