Load a scene as instances - problem

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
gmillas
Licensed Customer
Posts: 45
Joined: Fri Jun 25, 2010 6:15 am
Location: Greece
Contact:

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
Attachments
Load Instances.lua
(4.73 KiB) Downloaded 303 times
Mithrandir
Posts: 12
Joined: Sun Jun 01, 2014 9:56 pm

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.
gmillas
Licensed Customer
Posts: 45
Joined: Fri Jun 25, 2010 6:15 am
Location: Greece
Contact:

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?
User avatar
grimm
Licensed Customer
Posts: 1332
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

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?
Linux Mint 21.3 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 535.171
Mithrandir
Posts: 12
Joined: Sun Jun 01, 2014 9:56 pm

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.
Post Reply

Return to “Lua Scripting”