Page 1 of 1

Lua script for updating Orbx/Ocs files?

PostPosted: Mon Apr 09, 2018 12:08 am
by oscartung
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.

Re: Lua script for updating Orbx/Ocs files?

PostPosted: Tue Apr 10, 2018 4:40 am
by roeland
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 79 times


-Roeland

Re: Lua script for updating Orbx/Ocs files?

PostPosted: Mon May 07, 2018 1:39 am
by oscartung
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'?

Re: Lua script for updating Orbx/Ocs files?

PostPosted: Fri May 25, 2018 5:37 am
by roeland
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?

Re: Lua script for updating Orbx/Ocs files?

PostPosted: Sun Jul 15, 2018 8:40 am
by oscartung
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?

Re: Lua script for updating Orbx/Ocs files?

PostPosted: Sun Jul 15, 2018 9:24 pm
by roeland
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())