So my implementation to get the rotation or mirrored state of a Group instance goes like this:
- Find a suitable child element within the Group to retrieve a Transform of. This is either a FamilyInstance, or a linebased element.
- Get the Transform either from the FamilyInstance itself, or from the direction of the linebased element's LocationCurve at the starting point (0).
- Instantiate a temporary new Group instance of the GroupType to retrieve a matching child element in the GroupType to compare Transforms with. (You have to do this extra hoop, as it's not possible to query elements within a GroupType).
- Get the matching Transform in that temporary Group and delete it afterwards or roll back.
- Compare the Transforms to retrieve the rotation/mirrored state of the Group instance.
The following code demonstrates this from the point you've found a suitable child element in the Group instance:
private Transform GetTypeChildTransform(GroupType groupType, Element child)
{
Document doc = groupType.Document;
using Transaction? t = doc.IsModifiable ? null : new Transaction(doc);
t?.Start("Temp instance to retrieve transform")
Group tempInstance = doc.Create.PlaceGroup(new XYZ(100000, 100000, 0), groupType)
IEnumerable<Element> typeChildren = GetChildren(doc, tempInstance.GetMemberIds())
Element typeChild = child is FamilyInstance
? typeChildren.First(e => e is FamilyInstance && e.Name == child.Name)
: typeChildren.First(e => e.Location is LocationCurve && e.Name == child.Name)
Transform transform = GetTransform(typeChild)
if (t == null)
doc.Delete(tempInstance.Id);
else
t.RollBack()
return transform;
}
private Transform GetTransform(Element element)
{
if (element is FamilyInstance instance)
return instance.GetTransform();
if (element.Location is LocationCurve curve)
return curve.Curve.ComputeDerivatives(0, false)
throw new ArgumentException("Element is not a familyinstance or a linebased element");
}