-- Creates a group node and connect to all the selected meshes -- -- @description creates a group and connect to all the selected meshes -- @author Beppe Gullotta, with the corrections of Thomas Loockx and the help of Slater Lewis -- @version 0.2 -- @shortcut alt+9 -- get the current selection local selection = octane.project.getSelection() -- find all the meshes in the selection local meshes = {} for _, node in pairs(selection) do if node.type == octane.NT_GEO_MESH or node.type == octane.NT_GEO_PLACEMENT then table.insert(meshes, node) end end -- only do something if we have at least 1 mesh if #meshes == 0 then error("at least 1 mesh node needs to be selected") end -- get the position of the selected node in the graph editor pos = selection[1].position print ("mesh node position =") print (unpack(pos)) -- create a group node with the number of input pins equal to number of meshes local objectGroup = octane.node.create { type = octane.NT_GEO_GROUP, name = "group", position = {pos[1]+25, pos[2]+75} } objectGroup:setAttribute(octane.A_PIN_COUNT, #meshes) -- connect each mesh to the group for pinIx=1,objectGroup:getPinCount() do objectGroup:connectToIx(pinIx, meshes[pinIx]) -- we can use pinIx because #pins == #meshes end