Printer Selecting

Hi All,

Apologies for my inability to code…

I’m trying to automatically print sheets to the correct paper size.

So I need to write a script which takes a list of strings, looks for particular phrases (A0, A1, A3) and applies a print setting accordingly.

I’ve read as many tutorials as I can and tried to put together a code which works, but unfortunately I’ve run out of knowledge and places to look…!

Any assistance would be gratefully received.

Thanks,

Mark

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

lst = IN[0]
printerOne = IN[1]
printerTwo = IN[2]
printerThree = IN[3]
result = []


	if 'A01' in str(lst):
		printSetup = printManager.PrintSetup	
		printSetup.CurrentPrintSetting = printerOne
        printManager.Apply()
		
	elif 'A1' in str(lst):
		printSetup = printManager.PrintSetup	
		printSetup.CurrentPrintSetting = printerTwo
        printManager.Apply()

		
	elif 'A1' in str(lst):
		printSetup = printManager.PrintSetup	
		printSetup.CurrentPrintSetting = printerThree
        printManager.Apply()
	

#Assign your output to the OUT variable.
OUT = Answer

Hey mate,

You need to start by iterating through each of the items in the input list and then you can perform conditional statements on each item.

Here would be a good place to start learning:

https://wiki.python.org/moin/ForLoop

Good luck!

Thanks Jeremy,

I gave it a go but can’t get it working, I’ll park it for now!

Cheers,

Mark