Coordinate System for Mirrored Families

I’m trying to write a script that will place families according to a coordinate system. I have this mostly working, but am getting some issues when trying to place families that are mirrored (FacingFlipped or HandFlipped). This fits into a system where we want to record family positions to generate in different contexts. Basically a desynchronous ‘copy’ command.

In my testing i’m getting some very strange behavior where the FamilyInstance.Location value of the new family does not match the point used to define the coordinate system if the family is flipped.

accounting for the hand and facing flips is giving me trouble. Here’s my test script:

Is it possible to place a mirrored family instance with the coordinate system alone? or can this only be done in two steps: FamilyInstance.ByCoordinateSystem → HandFlipped? I’m trying to make this pretty generic so the cs data can be simply stored and elements can be generated in one command.

Magenta toilet family is a reference from a project. model geometry exists in the lower left quadrant. I’ve included an annotation to indicate the family origin graphically. The trapezoid is a test family with geometry existing in the upper right quadrant

Rotation works:

But mirroring the target family doesn’t create the correct change in the new family

And then lots of very strange behavior when creating a different type of the same family

This last test makes me think there is something incorrect with the way this family is built…

My approach is to create the coordinate system assuming that the family is not mirrored and that the z axis is the canonical Z. then you should just be able to mirror the cs used for generation, right? I think i’m missing something here.

Update:

The incorrect rotation in the last clip seems to be caused by shared nested components. I’m not completely sure how it chooses which point to set as the ‘base point’ because the family basepoint is clearly relocating. I was able to address this in the procedure i was writing by using the Element.SetLocation node after applying creating the family (or applying a transform). This resets the Family Instance location.

I was unable to instantiate a mirrored instance of the family as part of the coordinate system using FamilyInstance.ByCoordinateSystem, but was able to identify families that needed to be mirrored and apply the associated flip