I have a problem which I have searched the forum for and unfortunately I’ve been unsuccessful.
The closest solution I found was a python code to find pairs of X,Y. The code is a few years old now and I believe this doesn’t work in Dyn. 2,0.
The post in question can be found here,
My problem is that I need to find pairs in two separate lists of coordinates X,Y AND Z. For the output i need the following,
A-List the duplicates B-List the unique items in the respective list. The output would list the duplicates in nested list as a pair AND the unique items in separate list. I have attempted to outline the process below and I’m wondering if this is possible using python?.
I have explored using the dictionary nodes but this hasn’t given me the solution. I’m still learning python and i feel this is required for the current task at hand. I cannot see if there are any packages for this or if it can be done with standard nodes?
I will follow up with a few images and a file if this provides more clarity.
I’m still pursing the solution so i will also post any progress that has been made.
I think your problem can simply be solved using the Point.PruneDuplicates (that directly gives you your unique list) node and the List.FilterByBoolMask node. I’ll give a try. Posting the screen here if I get anything.
So i gave it a shot. It’s a little difficult to follow the code blocks and I’m trying to work out the sequence.
However, i have used copy paste from the file you sent.
Unfortunately the end result spits out an empty list. The two lists i have used are identical lists.
Sorry, this was an old image before i ran the script. The point prune node runs as expected. I will update the image.It still gives an empty list at the end.
From what I see, everything is running normal : you have as much input points as unique points (output of PruneDuplicates) : 672 points in total.
As you have no duplicates, the list supposed to contain your duplicates have none : your list was already duplicate free.
Maybe I did not understand your initial post : do you want to extract unique points and duplicates from each sublist independantly or do you want to compare the sublist between one another ?
Hi there,
Thanks for your patience with this.
I believe I’ve initially failed to understand how the prune node works. From this example it looks like it removes duplicates from each list as a separate process and doesn’t compare the two lists.
This is why the total is unchanged @ 672.
However, the two lists are identical to each other. For example. (LIST 0 [10,20,30,40] LIST 1 [10,20,30,40]
If i flatten the list and then use the prune node it reduces the list to 336 (half of the original) This has removed the duplicates. So it would appear that one part of the problem can be solved by using the prune node. However, in contrast to the example given. We have a list of duplicates and unique items. We need to get a list of the duplicate values and not simply a cleaned list discarding duplicates.
It appeared the answer you gave above performed this task by giving an output of lists that contained nested lists with two duplicate items. It doesn’t appear to work with the data set I have for some reason?
I’m going to look at this further.
Note: by performing a flatten i still get the same result “empty list” for the end output.
Ok, i re-worked the graph so it can work as you first expected. Note that this version will also work if the two inputs are not exactly the same. In this file, I put in the first input two list, one of 10 different items, and one with the same 10 points and 1 extra point. As you can see, the unique items list contains the eleven points distinct points, and the duplicate items list contains each pair of duplicates.
Note : if you want to put even more lists and get more duplicates, you can simply change the if(num==2) by if(num>=2).
Note : if you want to get the unique item of each sublist (and not of the merged list), you can simply apply the Point.PruneDuplicates to the initial sublists, that should do the trick.
Hi there,
I almost made a new post for this additional question however it’s such a similar query that I’ve included it on here. I can make a new post if required.
I’m wondering if a similar graph to above can be created to pair two lists of strings.
In this example I have a string of coordinates and I’ve attached a beam size to each coordinate. I would like to get a pairing of these two list strings using a similar work flow to before.
See images below for the data syntax of which i would like to pair.
I believe I’ve solved it.
I used a filter by boolmask to compare the list strings.
To test this out i changed 20 beam sizes in the model to another size. This resulted in the boolmask excluding these beams as the “==” output became false for these conditions. This was confirmed as the count was 316. (-20 from the original 336)
Note, the “==” node was set to cross product so that each item in turn is checked against the other list. To obtain the 20 beams that did not match (beams previously changed) I performed another boolmask but this time i made the lacing of “==” to shortest to obtain the 20 beams in the “out”
This is what i needed.
Hi there Mellouze,
Unfortunately I have one further question relating to the geometry almost equal to node.
I tried moving the model by 1/16" inch and then ran the script again. The script did not generate pair for some reason?
Using the same scenario as before, I have a list of points taken from an excel import. I generate points in dynamo from the excel points.
I then get the end point locations of the modeled geometry in revit. For testing purposes the points generated come from identical versions of a model. Now, when i move the revit model by a small amount and run the script, it doesn’t generate the pairs of points.
I do not know how really works this node, so I cannot tell you anything about how it behave. However I can suggest that instead of running the node, you use Geometry.DistanceTo and test if that distance is inferior to some threshold.
I am currently not at work, so I don’t have access to Dynamo. Try it on your own I and I will see what I can do on Monday.
Yes, it’s perfectly fine.
Just to let you know that I created a work round by setting the accuracy of the points before the pairing tool is used. The added workflow essentially creates points from a list of string coordinates. Once the numbers are isolated then I use a math round and define the digits. I made a custom node for this process.The node should work for all lists of points x,y,z in string format. I haven’t investigated the logic behind the “geometry.DistanceTo” however, i will get to this soon.
I will post the custom node shortly. “ConvertStringCoordToNumbers”
Thanks