Mirror Revit Familys

Hi
I am Dynamo beginner. I’m trying to mirror back allready mirrored families in Revit.

I often need this with mirrored buildings. Unfortunately, I can not find a mirror node. In my example, the families rotate around the axis.I need a similar solution that can mirror and delete the origin family.

Thanks
GianfrancoRotate Family.dyn (2.8 KB)
Mirrored Familys.rvt (612 KB)

Hello Gianfranco,

Bakery has a node called: Mirror an Element, that be might of use:

1 Like

Thank you for the answer.
That helped me alot. With the script I can now mirror multiple Elements around the own axis.

The next step is a selection set of the old objects, and then delete after running.
I have tried a lot but no solution.

Have you tried using a delete node in the same graph? For instance Element.Delete from Archi-lab:

1 Like

I did a little test and with some help from the Clockwork node ‘Passthrough’ this should work:

2 Likes

I thank you. that is the solution

hi, i do the exact same thing and i get no errors but nothing changes in my model space…
nothing gets mirrored, any idea?

fixed , i had to use Levels in ElementList

This node and python didnt work for me with R2018.1, until I changed the following;
From;
return Autodesk.Revit.DB.Plane(normal1, origin1)
(Gave error ‘Cannot create plane as it has no public construct’)

To;
return Autodesk.Revit.DB.Plane.CreateByNormalAndOrigin(normal1, origin1)

2 Likes

Another small improvement.
If you use MirrorElements instead of MirrorElement, then it is possible to choose if a new copy will be placed or the original will just be flipped.

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

For anyone comming across this thread:

Have the elementatransformutils throw everything into a variable. This should give you the IDs of the newly created items.
X=ElementTransformUtils.MirrorElements(doc, icollection, rp, copyyn)

You can also put the f.id within the parenthesis of the constructor like so:
List[ElementId](f.id)