i am starting to work on a script and would like to have your ideas to find the best workflow in Dynamo.
I have hundreds of points and a lot of alignments lets say 10 alignements.
For each point i would like to get the nearest alignment, what would you think to be the better/fastest way to get it?
I haven’t tested this, but here’s my idea:
Get the station/offset for each point relative to each alignment (using cross-product lacing)
Use List.SortByKey to sort the alignments by the offsets
Get the first item in the list, which will be the closest alignment (i.e. minimum offset)
@JowennLua actually just brought this up at his Q&A session this year, that last year (2019) the included data set has a initial script he made for determining the closest alignment.
https://www.autodesk.com/autodesk-university/class/Dynamo-Civil-3D-Introduction-Unlocking-Mystery-Scripting-2019#downloads ___ D4C3D_Query_Pts_vs_Align.dyn (70.3 KB)
Great suggestion @mzjensen, I tried it out on Cogo points and that list sort is a great method just still tricky to figure it out. It’s also key to take the absolute value of the offsets. The script will throw warnings if the points aren’t in range of one of the alignments but should still process. I created an Mtext with the pertinent info so you can see the result. Hope this helps!
D4C3D_Query_Pts_vs_Align-KM.dwg (925.3 KB)
D4C3D_Query_Pts_vs_Align-editV2.dyn (89.5 KB)
I like your answers @mzjensen it always seems obvious reading it!
I don’t think often enough to the List.SortByKey node and it is really powerfull…
Oh , i knew i saw a video showing this workflow but could not remind where and when it was ! That is this class of @JowennLua thanks a lot for the link i will put it on my favorites now.