Auto Numbering with line

hello all,
for only horizontal fittings, numbering should start from bottom to top,
my current script is going top to bottom.
for vertical fittings i have no issue.
please give me some suggestion, how it can be done!!
sample1.rvt (5.4 MB)
auto numbering.dyn (58.8 KB)



Hi @vishalghuge2500 ,

You’re on the right track! I made some modifications to automatically sort them from bottom to top. I also overhauled your current script because some of your logic is questionable :smiley: .


2023-10-17 Number ParameterValues according to PolyCurve + Sort Nearby Elements from Bottom to Top.dyn (61.4 KB)

Python Script:

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

def group_elements_by_threshold(elements, keys, threshold):
    result = []  # Initialize the result list

    current_group = []  # Initialize the current group
    current_key = None  # Initialize the current key

    for element, key in zip(elements, keys):
        if current_key is None:
            # First element, start a new group
            current_group.append(element)
            current_key = key
        else:
            if abs(key - current_key) <= threshold:
                # Key is within the threshold, add the element to the current group
                current_group.append(element)
            else:
                # Key is outside the threshold, start a new group
                result.append(current_group)
                current_group = [element]
                current_key = key

    if current_group:
        result.append(current_group)  # Append the last group if not empty

    return result

OUT = group_elements_by_threshold(IN[0], IN[1], IN[2])

PS: When working in Dynamo 2.x use the Clockwork 2.x version instead of the 1.x

1 Like