Page 1 of 1

Load a scene as instances - problem

Posted: Thu Jun 19, 2014 10:15 am
by gmillas
I have create a lua script that can load meshes and insert them as instances . It was working until version 2.00 . Now for some unexplaind reason it stops.

Here is the script

Re: Load a scene as instances - problem

Posted: Fri Jun 20, 2014 3:07 pm
by Mithrandir
Hey gmillas,

Looking at your code you have the line:

Code: Select all

local cursel = octane.project.getSelection()[1]
The getSelection() function returns a table.
So later, your code reads:

Code: Select all

		parent=cursel
		group= parent:findItemsByName("GROUP")[1]
		print(group)
		meshout=parent:findItemsByName("GEOM_OUT")[1]
		print(meshout)
The findItemsByName() function needs to be called by a "graph" type object.
cursel is simply a table with no methods attached. What you want to do would be:

Code: Select all

local cursel = octane.project.getSceneGraph()
Then of course you will actually need nodes named GROUP and GEOM_OUT.
Happy coding.

Re: Load a scene as instances - problem

Posted: Sat Jun 21, 2014 4:19 pm
by gmillas
Thank you for your response .

but as you can see the [1] takes the first selected out of the table

local cursel = octane.project.getSelection()[1] <- this

and my problem is not here

the problem starts when i check for the parent owned NT_IN_MATERIALS for existance by name
and more specific when i try to add new NT_IN_MATERIALS to the parent that are not inculed ...

if i have a fresh GT_STANDARD node just created by the the script and thus no NT_IN_MATERIALS exist , the script works well.......

Any ideas?

Re: Load a scene as instances - problem

Posted: Sat Jun 21, 2014 5:48 pm
by grimm
Finding nodes by name has always been a bit problematic, it's probably better to search for the nodes by type instead. I'm unable to really test your script because I don't have the instance file and all the other files behind it. Do you get any kind of error message?

Re: Load a scene as instances - problem

Posted: Sat Jun 21, 2014 5:50 pm
by Mithrandir
Sorry gmillas,

when I first tried run the script, I didn't have a file for defining objects and transforms
so it failed with the cursel when I bypassed the file lookup code and mistakenly assumed
octane.project.getSelection()[1] would be for a render target as in so many other scripts.
A whole mess of objects were scattered about, pretty cool, and so I thought that may have been
the problem. No, my head hurts and more in-depth study is needed when I have time.