Rotate assembly origin issue

Hello,

My question is not new, here is link to discussion and solution looks good. But I have the issue like on picture below. The problem that I don’t know how to fix that, according apidocs this method still available.

image

import clr
import math
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

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]
elems = tolist(UnwrapElement(IN[1]))
axis = tolist(IN[2])
rot = tolist(IN[3])

outList = []
if run:
	for e, a, r in zip(elems, axis, rot):
		trans = e.GetTransform()
		transRot = trans.CreateRotationAtPoint(a.ToXyz(),math.radians(r), trans.Origin)
		try:
			TransactionManager.Instance.EnsureInTransaction(doc)
			e.SetTransform(transRot)
			TransactionManager.Instance.TransactionTaskDone()
			outList.append(e)
		except Exception:
			outList.append(e.message)
	OUT = outList
else:
	OUT = "Please set Run to True"

Try changing trans to Transform
transRot = Transform.CreateRotationAtPoint(a.ToXyz(),math.radians(r), trans.Origin)

I believe in this line you want to create a new transform (called “transRot”) to set the transform properties of the element to and not trying to change the attribute of the element’s existing transform. Then you are applying the new transform properties to the element in the e.SetTransform(transRot) line. I am no means proficient when it comes to coding, so I may not be stating this correctly.

2 Likes

Thank you, @staylor. I’ve saved a ton of time for me!