Copy element using loop script

Hey everyone!
I’ve been working on a Dynamo code today and ran into some issues I’m fairly certain could be solved, but still need ome help.

The code I wrote takes the location and linear dimensions of shafts, then fits a shaft opening detail family to the shaft’s dimensions and places them on those shafts. I added pictures of before and after I ran the code.

My problem is with the placement of the detail families: right now, I need the number of shafts to be equal to the amount of detail families before I can successfully run the code, and I want to be able to only place one detail family in the view and copy it until it matches the amount of shafts in the view.

I know it’s probably possible using one of the script nodes, but I haven’t understood how to use them successfully yet and need some help.

Thank you for your help!


This part is confusing me. Why do you need the shafts and the detail items to both exist ahead of time? Isn’t that what you’re trying to automate?

Why not get all shaft instances and locations and then just create new detail items at those coordinates?

That is what I’m trying to automate, but I’m struggling to figure out which nodes to use and how to connect them. That line explains how the code works right now.

We can’t give you much direction without seeing your graph, but my previous comment still stands. It would probably be best to get the shaft locations and create new detail items rather than copying existing ones.

2 Likes

Hi nadav,

There are multiple ways to create instances of a family with Dynamo. You can find all the methods under Revit->Elements->FamilyInstance:

As Nick suggested, if you already have location and sizes of the shafts you can use FamilyInstance.ByPointAndLevel to place as many detail families as needed and Element.SetParameterByName to adjust their dimensions:

Place Detail Items.dyn (51.1 KB)

Hey!
Thank you for your help! I managed to get the code to work thanks to your advice! I was struggling to place the family in the right view- it was placing them in the architectural view and I needed them to be in the structural view, but I found a springs node that helped me with that.

Thank you for helping out!