Distance between two lists, and take those within a range

Hi all!

I have two lists on the left…I want to find the distance of each item on the first list…then group those which is lesser than 300… I can do this by the above node but it results a very big list (83349).
Is there a better way to collect those items?
Thanks!

Kia ora @newshunhk - without seeing how you’re getting your data this is a little harder :slight_smile:

But, typically you want to pre-filter as much things as possible. Instead of getting the distance of every single thing to your chosen set, can you look to slim this down? For example, by level, or by region, or by room?

1 Like

Not sure why, it’s faster using python.

Both lists should be flattend if you use below as it is.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line
geos1=IN[0]
geos2=IN[1]
min=IN[2]
bools=[]#determin set
dists=[]#distance between set
for geo1 in geos1:
	temp=[]
	dtemp=[]
	for geo2 in geos2:
		bool = False
		dist=geo1.DistanceTo(geo2)
		if dist<min:
			bool=True
		dtemp.append(dist)
		temp.append(bool)
	bools.append(temp)
	dists.append(dtemp)
	
# Assign your output to the OUT variable.
OUT = bools,dists
1 Like

thank you! then I try python for your script :slight_smile:

I would suggest the start time python code outputs into the other nodes to get a “True” representation of time. You could do this via a passthrough nodes or code so as not to mess up inputs, this will then definitely do the start time before the node you are measuring has started.

This is because Dynamo does not always do things in the same logic that you may think of, therefore it may be running them out of order. This will then give you incorrect time measurements!!

Example is that it might run them in this order:

I know what you mean. I just used it for comparing, not for getting real time taking.
Thanks for your advice. :slight_smile:

2 Likes

I just tested time taking using TuneUp(from Dynamo Team)…and got the same result. Just wanted to let you know.
Any one knows why?(using python is a bit faster than using the original nodes)

2022-03-03 12_35_19-Dynamo

2022-03-03 12_34_35-Dynamo

Based on numerous different machine factors, those numbers will vary slightly every time you run :smiley:

Run order in Dynamo is based on an AST (Abstract Syntax Tree) that is generated from the topology of your graph and forms the execution order of the nodes. This is why things like Passthrough works to help curate how the AST is created, as delta-compute (Only running bits of the graph that have had changes, and not re-running nodes that would output the same result) will optimize your graph execution.

2 Likes