Grouping geometries using LUA

Forums: Grouping geometries using LUA
Forum for OctaneRender Lua scripting examples, discussion and support.

Grouping geometries using LUA

Postby manalokos » Tue Aug 25, 2015 10:27 pm

manalokos Tue Aug 25, 2015 10:27 pm
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
manalokos
Licensed Customer
Licensed Customer
 
Posts: 438
Joined: Fri Nov 18, 2011 4:43 pm

Re: Grouping geometries using LUA

Postby bepeg4d » Wed Aug 26, 2015 1:45 pm

bepeg4d Wed Aug 26, 2015 1:45 pm
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
Attachments
bg4d-connect-group-02.lua
(1.31 KiB) Downloaded 742 times
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9954
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Grouping geometries using LUA

Postby manalokos » Wed Aug 26, 2015 5:41 pm

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

I'll give it a try tonight.

Kind regards
Filipe
manalokos
Licensed Customer
Licensed Customer
 
Posts: 438
Joined: Fri Nov 18, 2011 4:43 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 15 guests

Sat Apr 20, 2024 3:13 am [ UTC ]