Lua script for updating Orbx/Ocs files?

Forums: Lua script for updating Orbx/Ocs files?
Forum for OctaneRender Lua scripting examples, discussion and support.

Lua script for updating Orbx/Ocs files?

Postby oscartung » Mon Apr 09, 2018 12:08 am

oscartung Mon Apr 09, 2018 12:08 am
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.
oscartung
Licensed Customer
Licensed Customer
 
Posts: 55
Joined: Wed May 21, 2014 5:33 pm

Re: Lua script for updating Orbx/Ocs files?

Postby roeland » Tue Apr 10, 2018 4:40 am

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


-Roeland
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1708
Joined: Wed Mar 09, 2011 10:09 pm

Re: Lua script for updating Orbx/Ocs files?

Postby oscartung » Mon May 07, 2018 1:39 am

oscartung Mon May 07, 2018 1:39 am
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'?
oscartung
Licensed Customer
Licensed Customer
 
Posts: 55
Joined: Wed May 21, 2014 5:33 pm

Re: Lua script for updating Orbx/Ocs files?

Postby roeland » Fri May 25, 2018 5:37 am

roeland Fri May 25, 2018 5:37 am
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?
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1708
Joined: Wed Mar 09, 2011 10:09 pm

Re: Lua script for updating Orbx/Ocs files?

Postby oscartung » Sun Jul 15, 2018 8:40 am

oscartung Sun Jul 15, 2018 8:40 am
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?
oscartung
Licensed Customer
Licensed Customer
 
Posts: 55
Joined: Wed May 21, 2014 5:33 pm

Re: Lua script for updating Orbx/Ocs files?

Postby roeland » Sun Jul 15, 2018 9:24 pm

roeland Sun Jul 15, 2018 9:24 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())
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1708
Joined: Wed Mar 09, 2011 10:09 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Tue Jan 22, 2019 5:39 pm [ UTC ]