Element ID being reused

Evening All

Seemed to of encountered an issue when placing family multiple times in a project using Dynamo script.

I have a script that reads an excel file to get coordinates for a building floor, i then use FamilyInstance.ByPoint to place a family at every point location.
This works great…

However, when I run through to process again selecting a different file for the next floor (different X,Y,Z values) the dynamo script removes all the objects placed on the previous floor and places the family instance at the new coordinate points.
Regardless of whether i save the revit file, exit both revit & dynamo after a single run. It just does the same removes previous set of elements and re positions them.

I have had a look at the element Id, of the family instances dynamo seems to be re-using these whenever i run the script.

Am I doing something wrong or missing something to fix the placements and place a new set objects…!

Hopefully someone can shed some light on this, I have seen that others have encountered similar issues.

This is intended behavior as dynamo would recreate elements on top of elements on top of elements otherwise.

Try using an element binding technique, or utilize Dynamo Player to run the graph instead.

1 Like

Hi @smusitano

You could use Dynamo Player or use this python to place family:

import clr

clr.AddReference("RevitServices")
clr.AddReference("RevitNodes")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc =  DocumentManager.Instance.CurrentDBDocument

import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *


def ptslist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

famType = UnwrapElement(IN[0])
pts = ptslist(IN[1])
lvl = UnwrapElement(IN[2])


elems = []

for pt in pts:
	TransactionManager.Instance.EnsureInTransaction(doc)
	elems.append(doc.Create.NewFamilyInstance(pt.ToRevitType(True), famType, lvl, Structure.StructuralType.NonStructural))
	TransactionManager.Instance.TransactionTaskDone()
	
OUT = elems

And here is the process in action showing difference between OOTB node and using transaction in python.

5 Likes

Hi Jacob

Thanks for the feedback, I am using Revit 2015 & Dynamo 1.2 due to client requirement, so unable to use Dynamo Player (unless Player is available for older Dynamo/Revit.

Hi Kulkul

Many, many thanks for the python, it has solved the issue works a treat.

Cant use Player as running Revit 2015 & Dynamo 1.2 due to client requirement.

Thanks again
Steve

Hi there!

Is it possible to upload the picture of the process in action? :slight_smile:

-Erik

Hi @Erik_Hegg

Sorry i don’t have the process now. But you could try the above code and let us know if you come across any issues. Cheers!