Page 1 of 1

Grouping geometries using LUA

PostPosted: Tue Aug 25, 2015 10:27 pm
by manalokos
Hello

I've been trying to make a geometrygroup with several geometries connected, using LUA.

But I cannot find the names of the geometrygroup pins, after some hours banging my head I was able to get the NT_GEO_GROUP to have more than 0 pins, but their names are a mistery to me...
Could someone show a example of this?

Thanks
Kind regards
Filipe

Re: Grouping geometries using LUA

PostPosted: Wed Aug 26, 2015 1:45 pm
by bepeg4d
hi,
here is a script prepared some time ago, I hope it could be useful also for you:
Code: Select all
-- 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

ciao beppe

Re: Grouping geometries using LUA

PostPosted: Wed Aug 26, 2015 5:41 pm
by manalokos
Thanks Beppe

I'll give it a try tonight.

Kind regards
Filipe