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.
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).
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.
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?
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
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