Load a scene as instances - problem

Forums: Load a scene as instances - problem
Forum for OctaneRender Lua scripting examples, discussion and support.

Load a scene as instances - problem

Postby gmillas » Thu Jun 19, 2014 10:15 am

gmillas Thu Jun 19, 2014 10:15 am
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 284 times
gmillas
Licensed Customer
Licensed Customer
 
Posts: 45
Joined: Fri Jun 25, 2010 6:15 am
Location: Greece

Re: Load a scene as instances - problem

Postby Mithrandir » Fri Jun 20, 2014 3:07 pm

Mithrandir Fri Jun 20, 2014 3:07 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.
Mithrandir
 
Posts: 12
Joined: Sun Jun 01, 2014 9:56 pm

Re: Load a scene as instances - problem

Postby gmillas » Sat Jun 21, 2014 4:19 pm

gmillas Sat Jun 21, 2014 4:19 pm
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?
gmillas
Licensed Customer
Licensed Customer
 
Posts: 45
Joined: Fri Jun 25, 2010 6:15 am
Location: Greece

Re: Load a scene as instances - problem

Postby grimm » Sat Jun 21, 2014 5:48 pm

grimm Sat Jun 21, 2014 5:48 pm
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 20 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 460.56
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1321
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: Load a scene as instances - problem

Postby Mithrandir » Sat Jun 21, 2014 5:50 pm

Mithrandir Sat Jun 21, 2014 5:50 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.
Mithrandir
 
Posts: 12
Joined: Sun Jun 01, 2014 9:56 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 19 guests

Fri Apr 19, 2024 11:24 pm [ UTC ]