Hi, Alexzive wrote:
Hello there :) ,I am a python newbie and need to run following code for a task in an external simulation programm called "Abaqus" which makes use of python to access the mesh (ensamble of nodes with xy coordinates) of a certain geometrical model. [IN is the starting input containing the nodes to be check, there are some double nodes with the same x and y coordinates which need to be removed. SN is the output containing such double nodes] Code: Select all for i in range(len(IN)): #scan all elements of the list IN for j in range(len(IN)): if i <> j: if IN[i].coordinates[0] == IN[j].coordinates[0]: if IN[i].coordinates[1] == IN[j].coordinates[1]: SN.append(IN[i].label)
data=dict() for item in IN: # (what a name! ;) data.setdefault(item.coordinates,[]).append(item) # provided coordinates is a tuple dupes=[items for items in data.values() if len(items)>1] should give you a resulting list of lists of elements in IN which occur more then once per coordinates. You can then decide which ones to remove or whatever. If you want to have the output only containing nodes to remove, the following would work: dupes=[] for items in data.values(): dupes.extend(items[1:]) HTH Tino
smime.p7s
Description: S/MIME Cryptographic Signature
-- http://mail.python.org/mailman/listinfo/python-list