Lua script to batch convert obj to orbx?

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
ArchPrime
Licensed Customer
Posts: 82
Joined: Thu Sep 25, 2014 11:39 am
Location: New Zealand
Contact:

Hi, just wondering of anyone has or can make a script to batch convert a folder full of obj files into orbx format?
With most users having accumulated libraries of hundreds of obj files over the years, this would be pretty tedious to do manually, but being so repetitive, it seems a logical candidate for automation?
Octane Render for ArchiCAD 22 plugin v4.x | Octane Standalone 4.x
( 2x Nvidia 980 Ti) x 6MB VRAM | Intel I7 4470K | 32GB RAM | Windows 10
ArchPrime
Licensed Customer
Posts: 82
Joined: Thu Sep 25, 2014 11:39 am
Location: New Zealand
Contact:

bepeg4d wrote:Hi,
did you see this old script?
viewtopic.php?f=73&t=37617#p165882
Let me know if you have issues with it.
ciao beppe
Hi thanks bepeg4d

Just scanning through that thread, it looks like the script was not working? not for current version of octane? & not for creating a bunch of individual orbx files?
I know almost nothing about Octane standalone or really the concepts it uses (I am just a wysiwyg ArchiCAD plugin user) - but from another thread got the impression an orbx file using an obj mesh needs a placement and geometry out node added by any such script for it to be usable as a proxy?
Octane Render for ArchiCAD 22 plugin v4.x | Octane Standalone 4.x
( 2x Nvidia 980 Ti) x 6MB VRAM | Intel I7 4470K | 32GB RAM | Windows 10
User avatar
roeland
OctaneRender Team
Posts: 1822
Joined: Wed Mar 09, 2011 10:09 pm

A basic script to create an ORBX file would look like this:

Code: Select all

-- get filename from the first script argument
-- arg contains the arguments passed in via the command line using the -a switch
local obj = arg[1]
local orbx = obj:gsub("%.%w%w%w%w?$", ".orbx")
local name = octane.file.getFileNameWithoutExtension(obj)

-- create the nodes
local G = octane.nodegraph.createRootGraph(name)
local M = octane.node.create{type=octane.NT_GEO_MESH, name=name, position={0, 0}, graphOwner=G}
M:setAttribute("filename", obj)
local P = octane.node.create{type=octane.NT_GEO_PLACEMENT, name=name.." position", position={0, 50}, graphOwner=G}
P:connectTo("geometry", M)

-- export to an ORBX file in the same directory
G:exportToFile(orbx)
print("exported to "..orbx)
Which can be executed from the command line (see docs):

Code: Select all

octane --stop-after-script --script export.lua -a path/to/mesh.obj
You can use octane.file.listDirectory to loop through a directory:

Code: Select all

for _, obj in ipairs(octane.file.listDirectory(path, true, false, true, recursive, "*.obj")) do
    -- do stuff
end
-Roeland
ArchPrime
Licensed Customer
Posts: 82
Joined: Thu Sep 25, 2014 11:39 am
Location: New Zealand
Contact:

Thanks Roeland!
Octane Render for ArchiCAD 22 plugin v4.x | Octane Standalone 4.x
( 2x Nvidia 980 Ti) x 6MB VRAM | Intel I7 4470K | 32GB RAM | Windows 10
Jasonr
Licensed Customer
Posts: 97
Joined: Tue Aug 02, 2016 2:08 pm

Is it possible for someone to explain how to load the script in OCTANE Standalone.
Seems that that script is in pieces. Is it possible to put as a whole correctly???

Unfortunately I have absolutely no idea with this script finction...

Thank you Archiprime.
ASUS Z10 PE-D8 WS/2 x XEON E5-2680 V4/64GB RAM/1xQuadro M5000/2x NVIDIA GTX TITAN Pascal/ Windows 10/ Archicad 20
ArchPrime
Licensed Customer
Posts: 82
Joined: Thu Sep 25, 2014 11:39 am
Location: New Zealand
Contact:

Hi Jasonr, it may need to be someone other than myself who advises (perhaps Roeland?) - I got side tracked by actual paying work, so never managed to follow up or delve further
Octane Render for ArchiCAD 22 plugin v4.x | Octane Standalone 4.x
( 2x Nvidia 980 Ti) x 6MB VRAM | Intel I7 4470K | 32GB RAM | Windows 10
Post Reply

Return to “Lua Scripting”