Mirroring a door type

Hello Problem Solvers, I am jus wondering is that possible to mirror a door using dynamo as we do in Revit.
In my case I don’t have flip controls and I have removed it. I have to do this for 20 different door types.

So any help would be appreciated! Thanks in Advance.
Door Mirror

Hey,

Perhaps try this?
image
Hope that helps,

Mark

2 Likes

Hello, dont think "flip hand orientation will work, without flips…without trying :wink:

2 Likes

Thanks for your time, @Mark.Ackerley. As @sovitek mentioned it works only with flip arrows placed in the family.

This is a handy place to start: MirrorElements Method (Document, ICollection(ElementId), Plane, Boolean)

3 Likes

Thanks for the link @jacob.small. I can understand what Revit actually needs but I jus wondering how to write a python script based on the link. I tried few from Bakery package but I get a error “Can’t Mirror the element away from host”!.

That is a valid error… come to think of it I don’t know that this would be any bit of a good idea… might actually make more sense to add the flip state to the family (I think that might be automatable as well).

Edit: confirmed as a possibility - NewControl Method

Remember that change would need to be made once per family, so if you have 20 types of one family it is a single manual edit, but if you have twenty families with one type… automate it.

2 Likes

Hi,

This should flip it, even if there is no flip ticked, just feed a door / list of doors…

image

import clr

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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

doc = DocumentManager.Instance.CurrentDBDocument

if isinstance(IN[0],list):
    doors = UnwrapElement(IN[0])
else:
    doors = [UnwrapElement(IN[0])]


TransactionManager.Instance.EnsureInTransaction(doc)

for door in doors:
    door.flipHand()
	
TransactionManager.Instance.TransactionTaskDone()

OUT = door.HandFlipped

Hope that helps,

Mark

3 Likes

@Mark.Ackerley …cool:)

Hi Mark,

Once again Thank you for your valuable time, It didn’t work in my door family, I removed the flip arrow from elevation as well. Do I need to make some changes in door family or in the script?
Door PY Mirror

Can you post one of the door families for people to test with @gokul.saravanan? Also, what Revit year are you in?

1 Like

Hi Guys,

Here is my door family and I am using Revit version 2021.
DOOR_2P_1HD_1A_1F.rfa (3.1 MB)

Hello
a solution with Python (without flip controls)

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

toList = lambda x : x if hasattr(x, '__iter__') else [x]
flipdoors = []
#Preparing input from dynamo to revit
doors = toList(UnwrapElement(IN[0]))

TransactionManager.Instance.EnsureInTransaction(doc)

for door in doors:
	locPt = door.Location.Point
	wall = door.Host
	hostLine = wall.Location.Curve
	normAxe = hostLine.Direction.Normalize()
	tf = Transform.CreateTranslation(normAxe)
	newPt = tf.OfPoint(locPt)
	plane = Plane.CreateByNormalAndOrigin(normAxe, newPt)
	
	doorId = door.Id
	DB.ElementTransformUtils.MirrorElement(doc, doorId, plane)
	doc.Delete(doorId)
	doc.Regenerate()
	# get all the doors in model
	newdoors = list(FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements())
	# get the last by Id value
	newdoors.sort(key = lambda x : x.Id.IntegerValue)
	lastDoor = newdoors[-1]
	# fix location
	lastDoor.Location.Point = locPt
	flipdoors.append(lastDoor)
TransactionManager.Instance.TransactionTaskDone()

OUT = flipdoors
5 Likes

Nice one @c.poupin I can see you use Mirror, can it flip it in all 4 direction ?

I don’t know, need to try, it seems a little more complicated because the element mirroring has to be achieved with an offset for the door to cut the wall

2 Likes

Thanks for sharing this tutorial! :slightly_smiling_face:

2 Likes

Hi @c.poupin, Awesome… Thank you so much. It worked…Much much appreciated!

2 Likes

Hi @Mark.Ackerley @sovitek @jacob.small , I like to thank you guys for your valuable time for spending on my topic to find a solution.

4 Likes

Hello! It doesn’t work for Revit 2022 :frowning: . It works for one door from the list and others remove

@maksin
can you share a sample rvt file to test?

Work on my side (Revit 2022.1)
mirror doors