Delete duplicated elements

Hi again don’t worry about these blue lines once u close the revit file after saving they will disappear, these line created by dynamo to study the beams coordination.

Thanks Bro, Hope to get more useful dynamo graph from you.:slight_smile:

1 Like

Hi,

I am testing your graphs and i am missing the DUPLICATE ITEM INDICES node.

Which package will i get this node in?

Sorry for digging up graves here :slight_smile:

Hey Gary,

i am sry for the late replay it from Archi-Lab_Grimshaw which isn’t available any more from archi-lab packages. but if you are interested i can send it to you.

Hi Mohammad,

I’m looking for Archi-Lab_Grimshaw and I can’t find it anywhere - is it possible you make it public?

Which Node do you need ?.

  1. Duplicate Item Indices
  2. Delete Items

Thanks

1 Like

For Duplicate indices:

Python Code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

mylist = IN[0]

a, seen, result, unique = mylist, set(), [], []
for idx, item in enumerate(a):
    if item not in seen:
    	seen.add(item)
    	unique.append(idx)        
    	# First time seeing the element
    else:
    	result.append(idx)
    	# Already seen, add the index to the result

#Assign your output to the OUT variable
OUT = unique, result

Delete Elements:

Python Code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument

x = UnwrapElement(IN[0])
o = []

TransactionManager.Instance.EnsureInTransaction(doc)
for i in x:
	ID = Autodesk.Revit.DB.ElementId(i)
	doc.Delete(ID)
	o.append(True)

TransactionManager.Instance.TransactionTaskDone()

OUT = o
1 Like

Thanks a lot this seriously helps me from a whole lot of pain on Valentines Day.

1 Like

How does that Delete Item node work because its not working like it should be

1- is this the node that i sent to you ?
2- You need the script to delete which type of elements

  1. I think I copied it correctly
  2. have a look at what I’ve done

I think you have forgotten the bit that says something like


in the code that you posted.

The good-will and effort that people like Konrad put into writing code needs to be respected- otherwise they will not make it available to the rest of us to use.

Andrew

5 Likes

The code need to be edited a little to add another input as true/false. anyway i will send you another code by today

1 Like

I think if you been reading from the beginnings i was clear that the nodes i got from the Archi-Lab_Grimshaw which again isn’t available anymore , and i think instead of digging this deep you could just come and help better than worrying about the copywrite thing, for sure all thanks to Konrad for these nodes. Have a good day Andrew.

1 Like

Here you go

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument

y= []
y.append(IN[0])
y = len(y)

x = UnwrapElement(IN[0])
o = []

TransactionManager.Instance.EnsureInTransaction(doc)
if IN[1] == True:
	if y == 1:
		ID = Autodesk.Revit.DB.ElementId(x)
		doc.Delete(ID)
		o.append(True)
	else:
		for i in x:
			ID = Autodesk.Revit.DB.ElementId(i)
			doc.Delete(ID)
			o.append(True)
TransactionManager.Instance.TransactionTaskDone()

OUT = o
2 Likes

First of all i agree with all what you said and i hope everyone to stand for helping perspective nothing more like what you said and thank you for sharing the script with us i will check it out. Looks good :+1:t2:

That sounds good to me, unless someone copy/pasted something from my website and put their name on it. That’s not cool. Other than that I don’t care. It’s code, and anyone can write the same thing. It’s not magical.

8 Likes

i try to delete materials w/ same name, got error message, both delete node and Python node not working, is it because “delete within list” issue?

elements = IN[0]
if not isinstance(elements, list):
elements = [elements]
TransactionManager.Instance.EnsureInTransaction(doc)
res = [doc.Delete(UnwrapElement(e).Id) for e in elements]
TransactionManager.Instance.TransactionTaskDone()

image

Im had Resolved in this, you can visit and download. :innocent:
https://chuongmep.com/Check-Element-Duplicate-Dynamo-Revit/

1 Like