I’d like to check whether a group is mirrored or not.
select groups: done
checking if familyinstance.facingorientation doesn’t work (probably because it’s a group)
So I figured if I’m able to check a group’s orgin point I can check if it’s mirrored or not.
(the x-vector points to the right: not mirrored, the x-vector point to the left: mirrored).
But I can’t get that part - and perhaps it’s not the way to do so.
If I ask the coordinates, I get the absolute coordinates - not useful.
EDIT
Try (my first) python to do the trick.
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
clr.AddReference("System")
from Autodesk.Revit.UI import TaskDialog
from Autodesk.Revit.DB import FilteredElementCollector
from Autodesk.Revit.DB import BuiltInCategory, ElementId
from System.Collections.Generic import List
# Required for collection
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_IOSGroups)
groups = collector.ToElements()
mir_groups = []
for group in groups:
try:
if group.Mirrored:
mir_groups.append(group)
except AttributeError:
pass # foor Symbols that don't have Mirrored attribute.
TaskDialog.Show("Mirrored Groups", "Mirrored: {} of {} groups".format(
len(mir_groups), len(groups)))
# SELECT MIRRORED WALLS DOORS
selection = uidoc.Selection
collection = List[ElementId]([group.Id for group in mir_groups])
selection.SetElementIds(collection)
OUT=[collection]
Which doesn’t work. Grrr. who can help me figure this one out?
(and if Mirrored is unavailable, can I get a group’s origin point to do the same? Because If a group is mirrored, the originpoint (example X-axis) is mirrored)
Hi @3Pinter ,
I don’t have a bulletproof solution but just a suggestion…
You could get all members of the group, filter out all elements that aren’t FamilyInstances and then check wether the family instances are mirrored or not. This will only work if none of the families used in the group in the first place are mirrored.
You actually need to only find the first family instance in each group instance and compare their Mirrored properties. Doesn’t matter if the original family instance was mirrored or not. If you have a model group that only contains system families you are obviously #*$&ed.
Very clever @Andreas_Dieckmann
so here’s a revised version of my previous post:
Given one instance of the group, you get to know wether any other instance of the group is mirrored or not!
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
def tolist(input):
if isinstance(input,list):
return UnwrapElement(input)
else:
return [UnwrapElement(input)]
def groupelements(group):
memberlist = []
try:
for member in group.GetMemberIds():
memberlist.append(group.Document.GetElement(member).ToDSType(True))
except:
pass
return memberlist
def getfirstfamilyinstanceorientation(groupelements):
try:
return UnwrapElement([i for i in groupelements if isinstance(i,Revit.Elements.FamilyInstance)][0]).Mirrored
except:
return False
groups = tolist(IN[1])
testvalues = []
testgroupvalue = getfirstfamilyinstanceorientation(groupelements(UnwrapElement(IN[0])))
for group in groups:
finstance = getfirstfamilyinstanceorientation(groupelements(group))
testvalues.append(finstance == testgroupvalue)
OUT = testvalues
That’s correct, I thought the rotation could have been evaluated but I can’t see how indeed. Thanks for your answer
Extra info: the methods concerning groups could be enhanced by a new functionality in Revit 2018:
No tv yesterday. I had to fiddle with this script of yours @Mostafa_El_Ayoubi!
Establishing a base (what is the non-mirrored version) is what I was missing.
Btw: I like the flexibility of defining an original as base because in my cause it’s applicable for all of my selected groups.
Since the selected groups are build in the same way, I can use my defined original group for all of the other groups, eventhough their name is different.
Yes, it matters a great deal. Imagine that in a group instance you’re checking the first family instance has been excluded. In that case you would compare the first family instance in your reference group with the second family instance in your test group. If both the first and the second family instance in the reference group have the same mirrored value it’s not a problem. But if those values differ you’ll get wrong results.
The image above illustrates that case: Checking the duplicate group against the original group will return that that the group was mirrored (which it wasn’t).
I want to spice things up. Or better said, the mirrored check has to be done on the first familyinstance of the group, not the ‘nested’ familyinstance of the group.
So if in group
curtain wall with custom family instance’s (so non system panel, let’s say a window)
door with shared families
I consider the list-level of elements in that group as:
L1, L2
|_ curtain wall
|_ window1
|_ window2
|_ system panel etc.
|_ door
|_ generic model shared
Now, the possiblity exists that the nested window1 is checked. But that’s kinda risky.
So, how to tweak this? Kinda stuggling to get it working
(in my case I can trigger by name if needed)