# Align multiple walls

**URL:** <https://forum.dynamobim.com/t/align-multiple-walls/49155>\
**Category:** Developers\
**Tags:** python, api\
**Created:** [April 10, 2020, 5:17pm UTC](https://forum.dynamobim.com/t/align-multiple-walls/49155 "2020-04-10T17:17:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giuseppe\_Dotto](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/giuseppe_dotto/32/76486_2.png) [@Giuseppe\_Dotto](https://forum.dynamobim.com/u/Giuseppe_Dotto)\
**Post date:** [April 10, 2020, 5:17pm UTC](https://forum.dynamobim.com/t/align-multiple-walls/49155/1 "2020-04-10T17:17:19Z")

</div>

Hi everyone,

I am trying to develop a script that can detect all those walls slightly out of axis from a reference line and change them aligning to that reference.

I could not get a method that give me the possibility to align two element.

Can someone suggest me a way to align 2 elements using the Revit API?

.

.

.

_previous test:_  
_At the beginning I thought just rotating the wall by a specific value could be enough but, once created the script, I figured out that it wasn’t work. It gave me back an error saying “Element(s) reversed”, one of those errors that force you to delete the element or cancel the operation._

---

<div class="post-metadata">

**Author:** ![Durmus\_Cesur](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/durmus_cesur/32/62638_2.png) [@Durmus\_Cesur](https://forum.dynamobim.com/u/Durmus_Cesur)\
**Post date:** [April 10, 2020, 10:17pm UTC](https://forum.dynamobim.com/t/align-multiple-walls/49155/2 "2020-04-10T22:17:16Z")

</div>

Hi,

Unfortunately, I don’t know if it’s possible to move/align directly with the elements on a wall.

But one of the ways I can think of:  
I’d put the wall in the group, and then I’d move it to the point Where I wanted it.  
It’s just a way.

Here’s an example of how to do it.

 ![1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/2/f22d64b6e5276c181c3d149e08fbb7c486760bbe.gif)  
 ![code](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/a/5afc9a35334708c8189362d8c22c25f88ddc0add.png)  
 ![code in package](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/b/8b52e807efd980c1fb012e720db33e60a7669594.png)

```
# Copyright(c) 2019, Durmus Cesur
# DC_Package
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

grouptype = UnwrapElement(IN[0])
location = IN[1].ToXyz()
a = []

TransactionManager.Instance.EnsureInTransaction(doc)

groups = doc.Create.PlaceGroup(location,grouptype)
a.append(groups.ToDSType(True))
	
TransactionManager.Instance.TransactionTaskDone()

OUT = a
```

---

<div class="post-metadata">

**Author:** ![Giuseppe\_Dotto](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/giuseppe_dotto/32/76486_2.png) [@Giuseppe\_Dotto](https://forum.dynamobim.com/u/Giuseppe_Dotto)\
**Post date:** [April 12, 2020, 4:58pm UTC](https://forum.dynamobim.com/t/align-multiple-walls/49155/3 "2020-04-12T16:58:11Z")

</div>

Hi @Durmus_Cesur, thanks for your answer.

Personally I don’t understand how this workaround of creating temporary groups for walls can allow me to align elements without having errors.

Anyway, one information that might be useful for you is that is actually possible to move and/or rotate elements without placing them in groups: you just need to call the class **ElementTransformUtils**. [https://apidocs.co/apps/revit/2019/781ad017-5ee5-f44b-5db2-e8e1f883ae5d.htm](https://apidocs.co/apps/revit/2019/781ad017-5ee5-f44b-5db2-e8e1f883ae5d.htm)  
An example of rotation of a wall is:

```
for wall, alpha in zip(walls, angles):
    centerPt = wall.Location.Curve.Evaluate(0.5,True)
    axis = Line.CreateBound(centerPt, XYZ(centerPt.X, centerPt.Y, centerPt.Z+100))
    ElementTransformUtils.RotateElement(doc, wall.Id, axis, alpha*math.pi/180)
```
