-- @description Vertical connect selected nodes -- @author Issa IK3D -- @version 0.1 -- @shortcut alt+v root = octane.project.getSceneGraph() selection = octane.project.getSelection() geo = root:findNodes(1, true) function connec2(un, deu) --print('pc un', un, un:getPinCount()) --print('pc du', deu, un:getPinCount()) for n=1, un:getPinCount() do if un:canConnectToIx(n, deu) then un:connectToIx(n, deu) break end end end local t = {} -- [pose.y , node] for e = 1, #selection do t[ math.floor(selection[e].position[2]) ] = selection[e] end local tkeys = {} -- sort y -- populate the table that holds the keys for k in pairs(t) do table.insert(tkeys, k) end -- sort the keys table.sort(tkeys) local tidx = {} -- corresponding idx y in sorted key for e = 1, #tkeys do tidx[ e ] = tkeys[e] end -- use the keys to retrieve the values in the sorted order for h, k in ipairs(tkeys) do if h+1 <= #tidx then connec2(t[tidx[h+1]], t[k]) end end