Creating node inside group

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
manalokos
Licensed Customer
Posts: 441
Joined: Fri Nov 18, 2011 4:43 pm

Hello

I am trying to make a script that will automatically connect an asset to a newly created placement node,
the script is working on the scene root but stops working when I do it inside a group because the placement node is still created on the scene root.
How can I get the location of selection and make the placement node appear on the correct spot to be able to connect it?
Thanks in advance.

Cheers
Filipe

Code: Select all

-- @shortcut    alt+p
local rendertarget = octane.render.getRenderTargetNode()
local camera = rendertarget:getInputNode(octane.P_CAMERA)
local pos = camera:getPinValue(octane.P_TARGET)
local selection = octane.project.getSelection()
nodepos = selection[1].position

local placementnode = octane.node.create
{

    type     = octane.NT_GEO_PLACEMENT,
    name     = "placement node",
    position = {nodepos[1], nodepos[2]+50}
}

matrix = {
 {1,0,0,pos[1]},
 {0,1,0, pos[2]},
 {0,0,1, pos[3]},
}


placementnode:setPinValue(octane.P_TRANSFORM,matrix)

placementnode:connectToIx(2, selection[1])
User avatar
bepeg4d
Octane Guru
Posts: 10325
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy
Contact:

Hi Filipe,
you need to specify the graphOwner, like:

Code: Select all

local placementnode = octane.node.create
{

    type     = octane.NT_GEO_PLACEMENT,
    name     = "placement node",
    graphOwner = group_name,
    position = {nodepos[1], nodepos[2]+50}
}
ciao Beppe
manalokos
Licensed Customer
Posts: 441
Joined: Fri Nov 18, 2011 4:43 pm

Thank you Beppe,

I've tried but it doesn't seem to work, and is confusing since you can have many groups with the same name.
How could I extract the owner of selection?

Kind regards
Filipe
User avatar
bepeg4d
Octane Guru
Posts: 10325
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy
Contact:

Hi Filipe,
try with:

Code: Select all

graphOwner = selection[1]:getProperties().graphOwner
ciao Beppe
manalokos
Licensed Customer
Posts: 441
Joined: Fri Nov 18, 2011 4:43 pm

Amazing!

How do you get to know all this?
I searched but couldn't find any information.

Thank you so much, it worked like a charm!
User avatar
bepeg4d
Octane Guru
Posts: 10325
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy
Contact:

Great to hear :D
I have spent some time on the lua api in the past :)
Happy Scripting,
ciao Beppe
Post Reply

Return to “Lua Scripting”