Mirror Revit Familys

Hmm… nothing is ever so easy…

Managed to get MirrorElements to work, but that method uses an ‘icollection’ of IDs, not a single Id or a list of ids…

This is the working version, IN[2] is true or false to copy the original element or not.
One thing I didnt manage to do is return the new mirrored elements as the output instead of the originals… if someone knows how that can be done it would be useful.
(elems.append before the whole transform?)

import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import * #ElementTransformUtils, Plane

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

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

clr.AddReference('System')
from System.Collections.Generic import List

families = UnwrapElement(IN[0])
planes = IN[1]
copyyn = IN[2] #mirror existing element (false) or make copy (true)
rvt_planes =list()
mirrored = list()
elems = list()
count = 0

def Dyn2RvtPlane(pl1):
	normal1 = pl1.Normal.ToXyz(True)
	origin1 = pl1.Origin.ToXyz(True)
	return Autodesk.Revit.DB.Plane.CreateByNormalAndOrigin(normal1, origin1)

TransactionManager.Instance.EnsureInTransaction(doc)
for p in planes:
	rvt_planes.append(Dyn2RvtPlane(p))
for f, rp in zip(families, rvt_planes): #rvt_planes
	try:
#		item.Flip()
		icollection = List[ElementId]()
		icollection.Add(f.Id)
		ElementTransformUtils.MirrorElements(doc, icollection, rp, copyyn)
		elems.append(f)
		count += 1
	except:
		count += 0
		elems.append(null) #To maintain list length if irror fails
TransactionManager.Instance.TransactionTaskDone()

OUT = elems, count
2 Likes