Hi There,
I need to set up some scope boxes that rotate with varying angles. I have this data in an excel format. I thought I try to do this in dynamo. I got as far as laying out the scope boxes but got stuck with rotating it. As I could not find ways to rotate the scope boxes, I turned to try it with some python using examples found in this forum. I have encountered a problem with extracting element.Id. I have read posts in this forum but can seem to get it working.
The error message is
“Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 45, in
AttributeError: ‘List[object]’ object has no attribute ‘Id’”
The code is below. I am new to python and hoping someone can help to demystify what is happening
import clr
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference(“RevitAPI”)
from Autodesk.Revit.DB import *
clr.AddReference(“RevitAPIUI”)
from Autodesk.Revit.UI import *
import System
from System.Collections.Generic import *
################### Definitions ###################
def tolist(obj1):
if hasattr(obj1,“iter”): return obj1
else: return [obj1]
################### Inputs ###################
scbox = IN[0]
sbox = tolist(UnwrapElement(IN[0]))
vec = IN[1]#.ToRevitType(True)
lneAxis = IN[2]#.ToRevitType(True)
angl = IN[3]
Wrap in a Transaction
for i in sbox:
#ElementTransformUtils.MoveElement(doc, sbox.Id, vec)
TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, sbox.Id, lneAxis, angl)
# Close Transactio
TransactionManager.Instance.TransactionTaskDone(doc)