Page 1 of 1

Creating node inside group

PostPosted: Fri Apr 12, 2019 4:22 pm
by manalokos
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])

Re: Creating node inside group

PostPosted: Mon Apr 15, 2019 4:40 pm
by bepeg4d
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

Re: Creating node inside group

PostPosted: Tue Apr 16, 2019 3:02 pm
by manalokos
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

Re: Creating node inside group

PostPosted: Tue Apr 16, 2019 3:16 pm
by bepeg4d
Hi Filipe,
try with:
Code: Select all
graphOwner = selection[1]:getProperties().graphOwner


ciao Beppe

Re: Creating node inside group

PostPosted: Tue Apr 16, 2019 3:19 pm
by manalokos
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!

Re: Creating node inside group

PostPosted: Tue Apr 16, 2019 3:47 pm
by bepeg4d
Great to hear :D
I have spent some time on the lua api in the past :)
Happy Scripting,
ciao Beppe