Creating a Python Loop & Mirroring a Family

I’m lost at sea and need little bit of help in the code of python. I would like to process a family that has a family parameter added called “flipped” which is a yes/no parameter. If the parameter is ticked ie Yes then the family is flipped. If it is No then the family stays as is.

I have been able to “manually” process a list of 3 families with the code in green.

But what I would like to do is to be able to process any number of families with a loop using python code (see code in pink) however I’ve got no idea of how to create a loop in python.

To active the code in pink it requires the nodes to be connected along the red dashed line. To deactivate the “manual” code the nodes between the red dashed lines need to be broken.
Flip_Test_05.dyn (32.7 KB)

Test_Flip_Project_05.rvt (1.4 MB)

The family in the Revit file contains a flip control which allows the family to be mirrored.

1 Like

Hi again @RLietz,

Have you checked out this post? This allows you to flip multiple families…

You could filter your families first by the checkbox parameter and where meets the condition you are after they will be flipped.

Cheers,
Dan

Thanks Daniel, for pointing to the post “Flip Work Plane Equivalent” I didn’t find it under a “mirroring” search. In my graph I am actually using a filtering process to locate the families that need to be mirrored, so that process works well.

I appreciate your posted python code, but in trying to understand the coding process, it would be helpful not only to myself, but others coming to grips with what does what in coding, that there is a little breakdown on what is happening in the code. (Just a thought to accelerating knowledge).

However in the end, and it was easier using the built node from the Clockwork package, as pointed out by Mostafa_El_Ayoubi.

The resulting graph for Mirroring or flipping multiple families is uploaded here. 5-MIRROR_FAMILY.dyn (5.7 KB)
Note the family requires a flip control in it, and some process to filter the families to only mirror those desired, I have used a family parameter named “flipped”.

Hi @RLietz,

I’ll be sure to add comments to my future code as I know it is frustrating trying to pick apart what’s being done if you are new to coding or unfamiliar with the Revit API or Python.

If you are interested in learning Python in Dynamo have a look at this post, there is a link that covers Python in some depth and you may find it helpful…

Thanks for the feedback though.
Dan

Once again, thanks Daniel for providing links to further our knowledge, isn’t that the beauty of the Hyperlink, as envisaged by Ted Nelson, Douglas Engelbart, Jeff Rulifson, Dan Ostroff and Tim Berners-Lee and foresight from Autodesk. (https://en.wikipedia.org/wiki/Hyperlink#History)