Cannot mirror door without its host using MirrorElements

Cannot mirror door without its host using MirrorElements

ABertzouanis9F98Y
Enthusiast Enthusiast
1,333 Views
6 Replies
Message 1 of 7

Cannot mirror door without its host using MirrorElements

ABertzouanis9F98Y
Enthusiast
Enthusiast

I am using the  MirrorElements method to mirror a door element on the other side of a wall, without copying it.  

https://www.revitapidocs.com/2017/36027166-d494-9937-74c2-d61197af3878.htm

 

Unfortunately I am getting the error "Can't mirror an instance without its host" which does not make any sense for me. In the Revit UI, I can mirror the same door without getting this message.

error.PNG

 

Please, refer to my python code below which takes an an input a single door. You can easily copy paste this to a python node in Dynamo to reproduce the issue.  

 

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from System.Collections.Generic import List
doc = DocumentManager.Instance.CurrentDBDocument

data = UnwrapElement(IN[0])

output=[]

ids=[]
ids.append(data.Id)
Ids = List[ElementId](ids)

from Autodesk.Revit.DB import Transaction

t = Transaction(doc, 'Name')
t.Start()
output = ElementTransformUtils.MirrorElements(doc, Ids, Plane.CreateByNormalAndOrigin(data.GetTransform().BasisY, data.Location.Point), False);
t.Commit() 

OUT = output

 

 

0 Likes
Accepted solutions (1)
1,334 Views
6 Replies
Replies (6)
Message 2 of 7

ABertzouanis9F98Y
Enthusiast
Enthusiast

I could do the same operation with the flipFacing method, but few of my door families do not have the double vertical family and they are not able to flip.

https://www.revitapidocs.com/2015/66eb8785-4225-509c-b6a3-0bf9fe1612b2.htm

0 Likes
Message 3 of 7

RPTHOMAS108
Mentor
Mentor

Find the point you are using for the origin of your flip plane.

 

With door basis Y as normal of plane you may be flipping the door outside the wall because location point of door family is not where you expect. Should move it into wall centre line.

 

Can probably intersect an unbound line (basis Y of door) with location curve of wall to find such a point.

 

I think generally the location point will be on the centre of the wall regardless of what is set for defines origin in family, so it may not be that.

0 Likes
Message 4 of 7

FAIR59
Advisor
Advisor
Accepted solution

That's Revit-logic for you. I guess the reasoning is that mirroring for most of all possible planes will fail.

There is a  workaround.

  • Make a group of the door.
  • Mirror the group
  • Ungroup

This can be accomplished in a single transaction.

Message 5 of 7

ABertzouanis9F98Y
Enthusiast
Enthusiast

@RPTHOMAS108 See below the amended code that mirrors the door from the host's position. Unfortunately the same message appears ("Can't mirror an instance without its host").

 

 

 

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from System.Collections.Generic import List
doc = DocumentManager.Instance.CurrentDBDocument

door = UnwrapElement(IN[0])
wall=door.Host
output=[]
ids=[]

ids.append(door.Id)
Ids = List[ElementId](ids)

from Autodesk.Revit.DB import Transaction
t = Transaction(doc, 'Name')

t.Start()
WallStart=wall.Location.Curve.GetEndPoint(0)
WallEnd=wall.Location.Curve.GetEndPoint(1)
Z=XYZ(WallStart.X,WallStart.Y,WallStart.Z+1)
output.append(ElementTransformUtils.MirrorElements(doc, Ids, Plane.CreateByThreePoints(WallStart, WallEnd,Z), False));
t.Commit()

OUT = output

 

 

 

The weird thing is that if door is copied by changing the MirrorElements parameter to True (see below), if the door Family has no Opening Cuts then the door is mirrored correctly. If the door Family has Opening Cuts then error "Instance(s) of 1810x2110mm not cutting anything" appears as Door overlaps with the existing Door's Cut and cannot find a Host, then you have to delete the newly created instance.

 

 

ElementTransformUtils.MirrorElements(doc, Ids, Plane.CreateByThreePoints(WallStart, WallEnd,Z), True)

 

 

 

So the problem only exist when MirrorElements method tries NOT TO COPY the element.

0 Likes
Message 6 of 7

ABertzouanis9F98Y
Enthusiast
Enthusiast

@FAIR59 Weirdly, your solution works perfectly! I am wondering if you could share bit of your intuition. Why a Group containing JUST A SINGLE DOOR can be mirrored whereas the DOOR ITSELF as a single element cannot be mirrored?

0 Likes
Message 7 of 7

FAIR59
Advisor
Advisor

my intuition is based on 2 notions:

  • the problem is a check for a host. Groups don't have a host, so the check is bypassed.
  • there are some cases where an element in a group can rotate more freely then the element itself.