# Replacing families using Dynamo

**URL:** <https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625>\
**Category:** Revit\
**Created:** [September 25, 2024, 6:38am UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625 "2024-09-25T06:38:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hwo.osa](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@hwo.osa](https://forum.dynamobim.com/u/hwo.osa)\
**Post date:** [September 25, 2024, 6:38am UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625/1 "2024-09-25T06:38:39Z")

</div>

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:

 ![OSA_Replace_DetailItem_With_Furniture_2024-09-25_08-47-50](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/a/7a3901ea00ecb28ddb24892f03c72093ed56216e.png)

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [September 25, 2024, 6:50am UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625/2 "2024-09-25T06:50:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hwo.osa](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@hwo.osa](https://forum.dynamobim.com/u/hwo.osa)\
**Post date:** [September 25, 2024, 7:39am UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625/3 "2024-09-25T07:39:41Z")

</div>

Gavin, thanks for the reply. I’ve been a long time viewer of your YT channel 🙂  
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):

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/c/fc7b4d39908d9fe02a13a6e0c7ad7ada63f5e035.png)

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.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [September 25, 2024, 7:56am UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625/4 "2024-09-25T07:56:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [September 25, 2024, 8:46am UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625/5 "2024-09-25T08:46:46Z")

</div>

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

Without checking for flips/mirrors:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/0/b06439f43d0ec4cb7099717ebc2d1a75686dc770.png)

With checking:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/1/a1638a45d53368daa3945bafaf36529e800387d4.png)

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

> **[Rotation Property](https://www.revitapidocs.com/2024/43aea45e-dd1c-6a35-2fd5-1f99356708df.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

@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](https://forum.dynamobim.com/uploads/short-url/cbJlnQKSb5R9Iz8lHM3QLOxjrzT.dyn) (26.6 KB)

 ![Account for rotation_2024-09-25_06-16-41](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/6/569be6432b24e94edf5019e67a4d4568fee0cd71.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [September 25, 2024, 9:11am UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625/6 "2024-09-25T09:11:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hwo.osa](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@hwo.osa](https://forum.dynamobim.com/u/hwo.osa)\
**Post date:** [September 25, 2024, 12:07pm UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625/7 "2024-09-25T12:07:26Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/5/9547477ece0631f8556103d08c3d956b02dccf9b.png)

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 🙂

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?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [September 25, 2024, 5:56pm UTC](https://forum.dynamobim.com/t/replacing-families-using-dynamo/104625/8 "2024-09-25T17:56:13Z")

</div>

> [@hwo.osa](#):
>
> Is there a node to get/set the total transform

Doable with the API, not sure about a particular node though. Maybe [Archi-Lab](https://forum.dynamobim.com/t/revit-2022-dynamo-2-10-package-not-showing-up-and-icons-missing/62933/7?), Clockwork, or GeniusLoci?
