Align multiple walls

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.

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.



# 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

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
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)
1 Like