Monday 5 November 2018

Brickalo - Modo Command Line file

A number of people have asked about using MODO command line to render LDraw .ldr files.  Links to Modo and the LDR importer for MODO are in the footer of the Brickalo site.  Modo is a free 30 day download from The Foundry - MODO_CL (Modo command line) will continue to work after the 30 day trial expires.  The LDR importer for Modo is donationware (and well worth a donation!).

My previous posts about using Modo are here...
https://cultofthebrick.blogspot.com/2018/03/modo-and-ldraw-part-1.html
https://cultofthebrick.blogspot.com/2018/03/modo-and-ldraw-part-2.html
https://cultofthebrick.blogspot.com/2018/03/modo-and-ldraw-part-3.html

I'm primarily using Windows but the principle should work on a Mac (but you will need to change the paths) - as far as I'm aware there is no LDraw>Modo plugin for Linux.

I've included the command line script below - or you can download the zip file containing the script and sample brickalo ldr file from here

To execute the command line in a cmd window your command line should look something like this...



Command line documentation for MODO can be hard to find and this may not be the best way to implement ldr rendering but it works for my requirements.  Remember that the camera placement noted in this script moves the camera to frame a Rainbow Lego Tower on Brickalo - for your model it will be different!   Also the camera target (where the camera looks at) will also likely be different.  I found controlling the camera framing and the camera target using ModoCL hard - I've spent quite a bit of time trying to convert a POVray camera to a Modo camera but to date I've not succeeded working out the maths to do the conversion reliably.

Create a "brickalo" folder in your home directory then either download the zip file above or create a file called brickalo.txt and copy and paste the code below (and you'll need your own myLegoFile.ldr too)...

#======================================================================================================================================
# BRICKALO MODO RENDER BY NEIL MARSDEN 2018
#Make sure both MODO and the LDRAW Plugin for Modo is installed
#Currently an LDRAW folder needs to be in C:\LDRAW Modo_CL does not see the LDRAW location set for the plugin in Modo
#But you still need to load the config file so that Modo_CL knows where the LDRAW plug-in is

#In the comand window copy and paste the following line - BUT MAKE SURE YOU CHANGE UserName to your UserName so mine would be "C:\Users\Neil\brickalo\brickalo.txt"
#"C:\Program Files\Foundry\Modo\11.2v2\modo_cl.exe" -config "C:\Users\UserName\AppData\Roaming\Luxology\MODO11.2.CFG" < "C:\Users\UserName\brickalo\brickalo.txt"

#Lots of people have this at the start of their modo scripts!
log.toConsole true
log.toConsoleRolling true
#=========  Open LDR File ==========
scene.open "C:\Users\UserName\brickalo\myLegoFile.ldr"
#=========  Move the Camera ==========
camera.transformTo Camera -0.228601471 1.172085693 -0.844499451 0 0 0 
#========= Create Mesh - this will be the camera target ==========
item.create mesh
item.name "cameraTarget"
transform.channel pos.X 0 
transform.channel pos.Y 0.175 
transform.channel pos.Z 0 
#========= Target Camera ==========
#Select the Camera then the Mesh then point the camera at the Mesh
select.subItem Camera set
select.subItem cameraTarget add
target set
#Changes the field of view (zoom)
camera.hfov 22
#========= Start Image Render ==========
select.Item Render
item.channel step 1
item.channel first 1
item.channel last 1
item.channel outPat "_<FFFF>"
#========= Render HD Landscape Resolution ==========
render.res 0 1920
render.res 1 1080
#========= Output the images BUT MAKE SURE YOU CHANGE UserName to your UserName! ==========
render.animation "C:\Users\UserName\brickalo\OutputImage" PNG
#========== Or render a turnaround animation - rem out the previous line and use this next line instead (remove the hashtag) - BUT MAKE SURE YOU CHANGE UserName to your UserName! ==========
#render.turntable "C:\Users\UserName\brickalo\OutputMovie.mp4" pyFFMPEGMP4 24 12.0 0
#WORKS?!

No comments:

Post a Comment