Sort of, but by checking if the input is a list, then if not then ensure it is a list so you have a consistent input. The purpose of the code below is to show how you might handle and validate your inputs. Note how I am ensuring inputs are as I need them. Firstly, I am ensuring elements are a list of elements so I can loop through them, then I am ensuring that it is just one line and one angle by converting to list and getting first item (you can do your own handling depending on the scenario, say if you want an axis and angle per element), then I validate the inputs and raise informative exceptions if they do not pass…
from Autodesk.DesignScript import Geometry as geom
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
from Autodesk.Revit.DB import *
Ensure object is a List of objects. If not a list, then it will wrap in a list.
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
# The Elements to rotate. Ensuring these are in a list as we will loop through them...
elems = to_list(UnwrapElement(IN))
# The Axis as a DesignScript.Line. We are only handling a single line, so convert to list and get first ensuring there is only one line. If you want to add some more handling for multiple lines then you could test for length equality of elements and axis lines...
axis = to_list(IN)
# The angle in degrees. We are only handling a single angle, so convert to list and get first ensuring there is only one angle. If you want to add some more handling for multiple angles then you could test for length equality of elements, axis lines and angles...
angle = to_list(IN)
# Validating inputs. You can add more validation depending on your requirements...
if IN == None or len(elems) == 0:
raise Exception("Element(s) cannot be null or empty")
if IN == None or not axis.GetType() == geom.Line:
raise Exception("Axis is either null or is not of Type DS.Line")
if IN == None:
raise Exception("Angle cannot be null")
# The output from this node...
outlist = 
# Main code...
# Loop through the list of Elements. We know this is always a list even if it is only one Element...
for e in elems:
# Try/Except should be used sparingly and you should really handle expetions properly, but is beyond the scope of this example...
# Transform the Element. Make sure you convert to Radians and also ToRevitType for the DS.Line...
ElementTransformUtils.RotateElement(doc, e.Id, axis.ToRevitType(True), math.radians(angle))
except Exception, ex:
outlist.append("Failed: " + ex.message)
OUT = outlist
Like I said, this is just an example, how you handle your inputs is up to you. You can also do some clever mapping depending on your inputs, similar to how the node lacing works, but this is a little more advanced.
Hope this helps.