Hello!
Does anyone know how to order the points along the perimeter? I am currently using “Sort Points as Perimeter” node from sastrugi.points package and it seems to be working as you can see for the straight portion of points but when it gets to the corners you can see from the polycurve that the points lose their order.
I would like the path (order) to be what the highlighted line is in both images.
Any feedback would be appreciated
Thanks!
Daan
January 12, 2022, 4:42pm
2
Hi @dolan.klock ,
I think the Traveling Salesman problem would interest you, take a look at these topics:
this is a deceptively complex math/geometry task.
If you google ‘Travelling salesman problem’ (as mentioned in the post link from Ewan) you will see what I mean.
Not the right answer for a Dynamo forum, but I have done something similar using QGIS (free/opensource)- which has algorithms specifically for working out nearest neighbours or shortest path. It is actually quite easy- just need some CAD lines, as shown in the example below.
You basically simplify using line to lines represent po…
Sounds like the traveling salesman problem. Did a quick google search, blatantly copied all the code from here:
did a few quick changes to adapt it to Dynamo and came up with the below result:
[DynamoSandbox_2017-12-22_14-36-56]
import System
import sys
pf_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86)
sys.path.append('%s\IronPython 2.7\Lib' % pf_path)
import math
import random
from cStringIO import StringIO
sys.stdout = StringIO()
def distL2((…
Hello,
New to the forum and please pardon my bad English.
I was having hard time with renumbering smaller areas (Mechanical shafts, etc…) with select model curve to renumber elements.
So I am creating a different method referring to “Traveling Salesman problem”
This gets me a point to re organize the point’s list so that they are recognizable at XY coordinate system.(List 1)
My next step is to re-sort the list order of my areas (List 2) so that it matches “List 1”
I followed video below …
I really do not know how to thank you, you give me the way
[image]
Although, I used this code:
import System
import sys
pf_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86)
sys.path.append('%s\IronPython 2.7\Lib' % pf_path)
import math
import random
from cStringIO import StringIO
sys.stdout = StringIO()
def distL2((x1,y1), (x2,y2)):
"""Compute the L2-norm (Euclidean) distance between two points.
The distance is rounded to the closest intege…
3 Likes
Hi @dolan.klock and welcome, not sure about the negative coordinates value, but give it a try:
2 Likes
This was solution here in “shortest path through points” post. replaced code block with my list of unsorted points and it worked!
Thank you!!!
1 Like