Replacing families using Dynamo

Hi folks,

So I’ve been playing around with a script to place family instances based on the location and rotation of an existing element from another Revit category as this is not possible OOTB.

The background is that my firm often uses detail elements for furnishing building designs in the early design stages, and at some point, if the proposal gets accepted, we transition towards a more “BIM compatible” workflow with actual “Furniture” elements instead of 2D overlays.

The setup seems simple enough: Get all instances of a selected detail item. Read their positions (x, y, z) and view on which they’re placed. Read their rotation relative to the x- or y-Axis. Select a furniture family to replace the detail items with. Place it using aforementioned position and rotation parameters. Lastly, delete redundant detail items.

However, my results have been… inconsistent. The position and rotation of the newly placed furniture elements are kinda “close enough” to their detail item counterparts, but rarely match exactly. Sometimes the rotation is right, but the location of the inserted element is not quite right, as if the origins of the families don’t match (which they do). Sometimes, the insertion point is right, but the family is rotated by 180°. The fact that two families can look exactly the same in a Revit view, but have different values for rotation, isMirrored, isFlipped and so on doesn’t exactly help either.

Anyway, is there someone on here who has dealt with these problems before and can share their experience?

Edit: This is the graph I’m using:

If a family is literally rotated 180 degrees, worth checking if the family and detail family are built facing the same way.

Generally get/set familyinstance rotation has given me consistent results in the past if you’re not using those nodes.

Gavin, thanks for the reply. I’ve been a long time viewer of your YT channel :slightly_smiling_face:
I just double checked and both families are facing the same way.
Below is an example of an existing furnished room built with detail items as furniture after running my Dynamo script (correctly positioned elements marked in green, incorrectly rotated elements marked red):

I’ve also added the dynamo graph in the original post as it won’t let me add more than one upload to a reply.

1 Like

Not sure how Element.GetRotation works, but my guess is it is taking the angle without accounting for if the instance has been mirrored.

It might be faster and easier to get the complete transform of the detail items, generate the new family instance via the transform.

1 Like

Yep I reckon that’s it, nice one @jacob.small … test below:

Without checking for flips/mirrors:

image

With checking:

image

My rotation node when dealing with point based families will return the Rotation property of an element’s LocationPoint:

@hwo.osa glad to hear the content has been handy. See below a script using some nodes from Crumple which accounts for the flip/mirror conditions in various combinations, and might at least solve the rotation bug. RE placement points that’s a big harder to determine, but if placement points are in expected locations it’s got me stumped. Maybe some families don’t have defined origin planes and the family has to assume its origin in some cases?

Account for rotation.dyn (26.6 KB)

2 Likes

My guess on the location is that one of the tables has constraints planes to adjust the size of the family, but that they aren’t maintaining a relationship to the origin.

1 Like

Thank you Jacob and Gavin!

I think I figured out why the positioning is sometimes off. The origin of the family is on the bottom left corner:

This means that for mirrored detail items, placing the family at the same origin as the detail item and rotating around the objects center will always result in a faulty rotation, no matter the input angle. You would need to place, rotate, then mirror to get the same exact transformation. I’ll try that and keep you posted :slight_smile:

Edit: @jacob.small when you say “complete transform”, what do you mean? Is there a node to get/set the total transform including isMirrored and isHandFlipped properties?

Doable with the API, not sure about a particular node though. Maybe Archi-Lab, Clockwork, or GeniusLoci?