Lua script to batch convert obj to orbx?

Forums: Lua script to batch convert obj to orbx?
Forum for OctaneRender Lua scripting examples, discussion and support.

Lua script to batch convert obj to orbx?

Postby ArchPrime » Fri Aug 25, 2017 12:11 pm

ArchPrime Fri Aug 25, 2017 12:11 pm
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
Licensed Customer
 
Posts: 82
Joined: Thu Sep 25, 2014 11:39 am
Location: New Zealand

Re: Lua script to batch convert obj to orbx?

Postby bepeg4d » Mon Aug 28, 2017 2:33 pm

bepeg4d Mon Aug 28, 2017 2:33 pm
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
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9940
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Lua script to batch convert obj to orbx?

Postby ArchPrime » Mon Aug 28, 2017 2:49 pm

ArchPrime Mon Aug 28, 2017 2:49 pm
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
ArchPrime
Licensed Customer
Licensed Customer
 
Posts: 82
Joined: Thu Sep 25, 2014 11:39 am
Location: New Zealand

Re: Lua script to batch convert obj to orbx?

Postby roeland » Tue Aug 29, 2017 10:43 pm

roeland Tue Aug 29, 2017 10:43 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
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1808
Joined: Wed Mar 09, 2011 10:09 pm

Re: Lua script to batch convert obj to orbx?

Postby ArchPrime » Tue Aug 29, 2017 10:46 pm

ArchPrime Tue Aug 29, 2017 10:46 pm
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
ArchPrime
Licensed Customer
Licensed Customer
 
Posts: 82
Joined: Thu Sep 25, 2014 11:39 am
Location: New Zealand

Re: Lua script to batch convert obj to orbx?

Postby Jasonr » Tue Oct 24, 2017 1:09 pm

Jasonr Tue Oct 24, 2017 1:09 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
Jasonr
Licensed Customer
Licensed Customer
 
Posts: 97
Joined: Tue Aug 02, 2016 2:08 pm

Re: Lua script to batch convert obj to orbx?

Postby ArchPrime » Tue Oct 24, 2017 1:23 pm

ArchPrime Tue Oct 24, 2017 1:23 pm
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
ArchPrime
Licensed Customer
Licensed Customer
 
Posts: 82
Joined: Thu Sep 25, 2014 11:39 am
Location: New Zealand

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 5 guests

Fri Mar 29, 2024 12:49 pm [ UTC ]