How to maintain input referenced geometry through a python component

im trying to recreate a workflow that used gh components in a single python node.

import rhinoscriptsyntax as rs

import ghpythonlib.treehelpers as th

import scriptcontext as sc

# import Rhino

seq = [x * dist + dist for x in range(count)]

intervals = [(x - dist, x) for x in seq]

def groupByPosition(pairs):

    newpairs = [[y for y in pairs if min(x) < y[1] < max(x)] for x in intervals]

    return sorted(newpairs, key=lambda x:x[0][1])

srfpairs = [[x, rs.SurfaceAreaCentroid(x)[0][axis], str(x)] for x in srfs]


b = th.list_to_tree(groupByPosition(srfpairs))

a = srfs

it basically takes in a bunch of referenced surfaces made from a imported cad file and sorts them by position, or its titleblock position. however i need the output to maintain its layer information, since the output are just geometry. i had a feeling scriptcontext might help, but still trying to wrap my head around it. my desired result would be this python node to act as a sorting mechanism, like how standard components do. I would appreciate any help in achieving this.

attached are the 3dm and gh file with what im trying to achieve.sort reference (30.5 KB) sort reference geo.3dm (10.3 MB)

i figured it out by reading related posts. i could either set the rhinoactivedoc or simply set the typehint of the srf input as guid

1 Like