Lua script for updating Orbx/Ocs files?

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
oscartung
Licensed Customer
Posts: 64
Joined: Wed May 21, 2014 5:33 pm

Hi there, I need some help creating a script which update an orbx/ocs node (like the update button for geometry?) as orbx/ocs files are being exported from different programs, and currently I have to delete the node and re-link them manually. Any help would be appreciated.
User avatar
roeland
OctaneRender Team
Posts: 1822
Joined: Wed Mar 09, 2011 10:09 pm

One possible way is as follows:
  • Clear any non-linker nodes in your graph
  • Import the ORBX file inside your graph
  • Connect all matching linker nodes: input linkers in your graph → input linkers in the imported graph, and the other way for outputs
  • Ungroup the original graph.
I'm using the following:
reload-orbx.lua
(3.32 KiB) Downloaded 410 times
-Roeland
oscartung
Licensed Customer
Posts: 64
Joined: Wed May 21, 2014 5:33 pm

roeland wrote:One possible way is as follows:
  • Clear any non-linker nodes in your graph
  • Import the ORBX file inside your graph
  • Connect all matching linker nodes: input linkers in your graph → input linkers in the imported graph, and the other way for outputs
  • Ungroup the original graph.
I'm using the following:
reload-orbx.lua
-Roeland
Hi Thank you for your reply, I'm having trouble getting this to work, would you mind elaborating what's a 'non-linker nodes' and 'matching linker nodes'?
User avatar
roeland
OctaneRender Team
Posts: 1822
Joined: Wed Mar 09, 2011 10:09 pm

matching linkers = linkers with the same type and name
non-linker nodes = any node which is not an input or output linker node

Does the attached script not work?
oscartung
Licensed Customer
Posts: 64
Joined: Wed May 21, 2014 5:33 pm

I couldn't get it working, maybe I am having trouble understanding it.

say I have a file with a simple obj exported from my 3D program.
I load it into octane, group it then rightclick save as A.orbx
then i put that A.orbx into another octane file B.orbx.

if I make some changes to A.orbx and save it, how do I update A.orbx loaded into B.orbx without having to re import it?
User avatar
roeland
OctaneRender Team
Posts: 1822
Joined: Wed Mar 09, 2011 10:09 pm

The script as is allows you to load B.orbx, select one or more node graphs and replace the contents of that with A.orbx.

You can do the same programatically, roughly like this (replace the part of the script below -- get selection):

Code: Select all

-- Open B

assert(octane.project.load([[path/to/B.orbx]]))
local B = octane.project.getSceneGraph()

-- Load A

local sourceGraph = octane.nodegraph.createRootGraph("")
assert(octane.nodegraph.importFromFile(sourceGraph, [[path/to/A.orbx]]))
local sourceItems = sourceGraph:getOwnedItems()
assert(#sourceItems == 1)
local A = sourceItems[1]

-- find node graphs to refresh. You'll need some way
-- to identify which graphs were imported from B.orbx:

local graphs = B:findItemsByName("B.orbx", true)

-- and refresh node graphs

for _, g in ipairs(graphs) do
    if g.graphType == octane.GT_STANDARD then
        replaceContents(g, A)
        print("Replaced graph")
    end
end

-- save
-- check carefully if this is working before actually saving

-- assert(octane.project.save())
Post Reply

Return to “Lua Scripting”