Group is mirrored (or not)


#1

I’d like to check whether a group is mirrored or not.

  1. select groups: done
  2. 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?

3Pinter


Wall is mirrored (or not)
#2

Can you share some other screen shots of the errors and the DYN? Might help.


#3

@Tom_Kunsman,

Sure Tom, but I guess even easier: see dyn file.

flipped.dyn (16.5 KB)


#4

Seems like the “mirrored” property for groups is not accessible through the Revit API:
http://www.revitapidocs.com/2017/684d5b96-5b9f-932c-2608-c127ccd2decb.htm
https://forums.autodesk.com/t5/revit-api-forum/modifying-groups/td-p/5456138


#5

Hmppfff that’s annoying.

However my current error is due indent block.

(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)


#6

A point doesn’t have any axis values, you’re probably thinking of the element coordinate system, but it’s apparently not accessible for groups either.


#7

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.


#8

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.


#9

Here is what you could get with Element.LocalCoordinateSystem (BIM4Struc) but it’s certainly not enough in itself to solve the issue:


#10

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

#11

While I’m testing your thoughts / ideas, I see your post @Mostafa_El_Ayoubi.

Trying that one too as well now!


#12

Very good idea, could also work this way:


#13

Not sure that would work… If a group is rotated (without mirroring) you wouldn’t get the same values.


#14

That’s correct, I thought the rotation could have been evaluated but I can’t see how indeed. Thanks for your answer :slight_smile:
Extra info: the methods concerning groups could be enhanced by a new functionality in Revit 2018:


http://www.revitapidocs.com/2018.1/2a695dff-8aa5-c266-1d4e-870483e9b5dc.htm


#15

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.

Thanks!


#16

Since I needed this to be a bit more robust, I wrote a slightly different version which also checks for the following:

  • Is checked group instance of the same group type as the reference group instance? (if not returns null)
  • Does checked group instance have any excluded members? (if so returns null)
  • Does reference group instance contain any family instances at all? (if not returns null for all groups)
  • Does reference group instance have any excluded members? (if so returns null for all groups)

File can be downloaded here:
https://raw.githubusercontent.com/andydandy74/ClockworkForDynamo/master/nodes/1.x/Group.IsMirrored.dyf


#17

@Andreas_Dieckmann,

Does is matter if a group has excluded members?

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.


#18

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


#19

Agreed @Andreas_Dieckmann , that does matter indeed. :+1:


#20

@Andreas_Dieckmann,

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 :expressionless:
(in my case I can trigger by name if needed)