Page 1 of 1

Lua script to batch convert obj to orbx?

PostPosted: Fri Aug 25, 2017 12:11 pm
by ArchPrime
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?

Re: Lua script to batch convert obj to orbx?

PostPosted: Mon Aug 28, 2017 2:33 pm
by bepeg4d
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

Re: Lua script to batch convert obj to orbx?

PostPosted: Mon Aug 28, 2017 2:49 pm
by ArchPrime
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?

Re: Lua script to batch convert obj to orbx?

PostPosted: Tue Aug 29, 2017 10:43 pm
by roeland
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

Re: Lua script to batch convert obj to orbx?

PostPosted: Tue Aug 29, 2017 10:46 pm
by ArchPrime
Thanks Roeland!

Re: Lua script to batch convert obj to orbx?

PostPosted: Tue Oct 24, 2017 1:09 pm
by Jasonr
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.

Re: Lua script to batch convert obj to orbx?

PostPosted: Tue Oct 24, 2017 1:23 pm
by ArchPrime
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