Hello,
I tried to write a script that aligns the axes of assembly origin point relative to the selected plane and rotates it 180 degrees around Z axis. I encountered this error and can’t understand what I’m doing wrong?
Here is an original code
This topic can’t solve my problem
import clr
import math
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript import Geometry as Geom
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 *
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
run = tolist(IN[0])[0]
assem = tolist(UnwrapElement(IN[1]))
plane = tolist(UnwrapElement(IN[2]))[0]
point = tolist(IN[3])[0]
normal = tolist(IN[4])[0]
outList = [ ]
if run:
a, p,pt,n = assem, plane, point, normal
ax = p.XAxis
ay = p.YAxis
trans = a.GetTransform()
trans.Origin = pt.ToXyz()
trans.BasisX = n.ToXyz()
trans.BasisY = ay.ToXyz()
trans_rot = trans.CreateRotationAtPoint(trans.BasisZ, math.radians(180), trans.Origin)
try:
TransactionManager.Instance.EnsureInTransaction(doc)
a.SetTransform(trans_rot)
TransactionManager.Instance.ForceCloseTransaction()
outList.append(a)
except Exception as ex:
outList.append(ex)
OUT = outList
else:
OUT = "Please set Run to True"