Creating node inside group

Forums: Creating node inside group
Forum for OctaneRender Lua scripting examples, discussion and support.

Creating node inside group

Postby manalokos » Fri Apr 12, 2019 4:22 pm

manalokos Fri Apr 12, 2019 4:22 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])
manalokos
Licensed Customer
Licensed Customer
 
Posts: 406
Joined: Fri Nov 18, 2011 4:43 pm

Re: Creating node inside group

Postby bepeg4d » Mon Apr 15, 2019 4:40 pm

bepeg4d Mon Apr 15, 2019 4:40 pm
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
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6594
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Creating node inside group

Postby manalokos » Tue Apr 16, 2019 3:02 pm

manalokos Tue Apr 16, 2019 3:02 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
manalokos
Licensed Customer
Licensed Customer
 
Posts: 406
Joined: Fri Nov 18, 2011 4:43 pm

Re: Creating node inside group

Postby bepeg4d » Tue Apr 16, 2019 3:16 pm

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


ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6594
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Creating node inside group

Postby manalokos » Tue Apr 16, 2019 3:19 pm

manalokos Tue Apr 16, 2019 3:19 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!
manalokos
Licensed Customer
Licensed Customer
 
Posts: 406
Joined: Fri Nov 18, 2011 4:43 pm

Re: Creating node inside group

Postby bepeg4d » Tue Apr 16, 2019 3:47 pm

bepeg4d Tue Apr 16, 2019 3:47 pm
Great to hear :D
I have spent some time on the lua api in the past :)
Happy Scripting,
ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6594
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Tue Sep 24, 2019 9:27 am [ UTC ]