# Origin rotate issue

**URL:** <https://forum.dynamobim.com/t/origin-rotate-issue/98297>\
**Category:** Developers\
**Tags:** python, dynamo\
**Created:** [February 21, 2024, 12:20am UTC](https://forum.dynamobim.com/t/origin-rotate-issue/98297 "2024-02-21T00:20:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleksei\_Gavris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Aleksei\_Gavris](https://forum.dynamobim.com/u/Aleksei_Gavris)\
**Post date:** [February 21, 2024, 12:20am UTC](https://forum.dynamobim.com/t/origin-rotate-issue/98297/1 "2024-02-21T00:20:33Z")

</div>

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](https://forum.dynamobim.com/t/assembly-modify-origin/11433/2)  
[This topic can’t solve my problem](https://forum.dynamobim.com/t/rotate-assembly-origin-issue/95863)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/4/b495eb1dac4d6f367839f0f7e18440a13daa91d6.png)

```auto

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"

```

---

<div class="post-metadata">

**Author:** ![pyXam](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/pyxam/32/163009_2.png) [@pyXam](https://forum.dynamobim.com/u/pyXam)\
**Post date:** [February 21, 2024, 12:49am UTC](https://forum.dynamobim.com/t/origin-rotate-issue/98297/2 "2024-02-21T00:49:49Z")

</div>

I am unsure if this will work but can you try investigate with the Element.SetRotation Node from GeniusLoci  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/5/7594171860ce5fe627aa7e27da09f22982f6d035.png)

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [February 21, 2024, 11:24am UTC](https://forum.dynamobim.com/t/origin-rotate-issue/98297/3 "2024-02-21T11:24:25Z")

</div>

> [@Aleksei\_Gavris](#):
>
> trans\_rot = trans.CreateRotationAtPoint(trans.BasisZ, math.radians(180), trans.Origin)

update to create a new transform rather than modify the existing - this is the solution from the second link:

```python
trans_rot = Transform.CreateRotationAtPoint(trans.BasisZ, math.radians(180), trans.Origin)

```

You could also look at using `ElementTransformUtils.RotateElement`  
API info here [RotateElement Method](https://apidocs.co/apps/revit/2024/3968f4e8-759c-f975-6c1f-7de42be633ed.htm#)
