This is a short description of commands that can be used to control Octane plugin with MaxScript.
(as of current version, 2020.1.4 - 10.14 . This list was first introduced in 3.06.4 - 4.38)
Those can be used to automate some tasks, add convenient shortcuts, trouble shooting or work around some issues.
-------------------- Actions ------------
First, there are actions that are exposed to the 3dsMax UI, that can be added/removed to 3dsMax menus, and bind to keyboard shortcut.
To see those available commands, open Customize / Customize User Interface in main 3dsMax Menu.
In the Keyboard, Toolbars, or Menu tab, set Group as Octane.
You can see the list of Actions, eg 'Do Material Conversion', 'Pause Rendering', etc..
You can assign those actions to menus, keys, etc, from this Customize menu.
And you can also call those actions from maxScript.
You can see the syntax and detail of each command by opening the MaxScript Listener window.
for example, opening the Octane viewport from the Octane menu shows:
actionMan.executeAction 982383860 "2642" -- Octane: Open Octane Viewport
(where 982383860 is a unique identifier for Octane Plugin, and 2642 is the code of the action)
The current list of actions is:
actionMan.executeAction 982383860 "6553" -- Octane: Clear Octane Scene
actionMan.executeAction 982383860 "6555" -- Octane: Edit Log File
actionMan.executeAction 982383860 "6554" -- Octane: Explore Scene Folder
actionMan.executeAction 982383860 "2169" -- Octane: Export Octane material
actionMan.executeAction 982383860 "8135" -- Octane: Export to Octane Proxy
actionMan.executeAction 982383860 "7394" -- Octane: Material Conversion - All
actionMan.executeAction 982383860 "7395" -- Octane: Material Conversion - Material Editor Current
actionMan.executeAction 982383860 "7396" -- Octane: Material Conversion - Selected Objects
actionMan.executeAction 982383860 "6547" -- Octane: Octane Automate
actionMan.executeAction 982383860 "6556" -- Octane: Octane Graph Viewer
actionMan.executeAction 982383860 "3289" -- Octane: Octane Live DB
actionMan.executeAction 982383860 "2398" -- Octane: Octane properties
actionMan.executeAction 982383860 "6557" -- Octane: Open Octane Log Window
actionMan.executeAction 982383860 "2642" -- Octane: Open Octane Viewport
actionMan.executeAction 982383860 "6544" -- Octane: Pause Rendering
actionMan.executeAction 982383860 "6551" -- Octane: Rebuild Scene
actionMan.executeAction 982383860 "3290" -- Octane: Refresh Live DB
actionMan.executeAction 982383860 "6552" -- Octane: Refresh Materials
actionMan.executeAction 982383860 "6545" -- Octane: Resume Rendering
actionMan.executeAction 982383860 "6548" -- Octane: Set Octane as Renderer
actionMan.executeAction 982383860 "6546" -- Octane: Toggle Pause Rendering
actionMan.executeAction 982383860 "6550" -- Octane: Octane Preferences
actionMan.executeAction 982383860 "6559" -- Octane: Open scene AOV Settings
actionMan.executeAction 982383860 "6558" -- Octane: Add Octane Preset helper
-------------------- Standard 3dsMax object access -------------
All Octane types and item properties are accessible via the standard maxscript way, using plugin class, properties, etc names.
for example, to set Octane as the current renderer, you can also use:
renderers.current = Octane3dsmax () -- assign renderer to octane3dsmax
A quick sample, that can be saved and run as a .ms file, to create an Octane 'Glossy material' with a RGB texture, assigned to a box:
>>>>
backgroundColor = white
mybox = box length:30 width:20 height:10 mapcoords:on
mybox.name = "myBox01"
newmat01 = Glossy_material()
newmat01.name = "myGlossyMat01"
texture01 = RGB_image()
texture01.name = "myTexture01"
setProperty texture01 "filename" "TexTest1.png"
newmat01.diffuse_input_type = 2
newmat01.diffuse_tex = texture01
newmat01.showInViewport = on
showTextureMap newmat01 texture01 true
mybox.material = newmat01
meditMaterials[1] = $myBox01.material
<<<<
---------------------- Additional Octane commands : OctaneMaxFPI interface ------------
Some other commands are available in the OctaneMaxFPI interface.
To list those commands, open the maxScript listener, and type
showinterface OctaneMaxFPI
The current list of commands is:
OctaneMaxFPI.OCMGetVersion()
: Return Octane plugin version as an interger, eg 4003800 for 4.38
OctaneMaxFPI.OCMSetUserConfigValue varName varValueString
:where varName is one of the User configuration variable (as in octane3dsMaxConfig.cfg)
eg:
OctaneMaxFPI.OCMSetUserConfigValue "EnableTexEnvPreview" "1"
OctaneMaxFPI.ViewportGetWindowState()
: Return 1 or 0 if Octane Viewport window is open or closed
OctaneMaxFPI.ViewportSetWindowState(1)
: Open Octane Viewport window
OctaneMaxFPI.ViewportSetWindowState(0)
: Close Octane Viewport window
OctaneMaxFPI.ViewportGetRenderState()
: 0: not ready / not rendering, 1 to 99 : preparing render, 100 : normal rendering
OctaneMaxFPI.ViewportGetControlState itemID
and
OctaneMaxFPI.ViewportSetControlState itemID, itemState
with itemID corresponding to the buttons of the Octane Viewport window.
eg:
OctaneMaxFPI.ViewportSetControlState 1 1 -- open save as dialog
OctaneMaxFPI.ViewportSetControlState 2 1 -- copy to max FB
OctaneMaxFPI.ViewportSetControlState 3 1 -- update
OctaneMaxFPI.ViewportSetControlState 4 1 -- lock update
OctaneMaxFPI.ViewportSetControlState 4 0 -- unlock update
OctaneMaxFPI.ViewportSetControlState 5 1 -- Pause
OctaneMaxFPI.ViewportSetControlState 5 0 -- Resume
OctaneMaxFPI.ViewportSetControlState 6 1 -- Focus picker On
OctaneMaxFPI.ViewportSetControlState 6 0 -- Focus picker Off
OctaneMaxFPI.ViewportSetControlState 7 1 -- White balance picker On
OctaneMaxFPI.ViewportSetControlState 7 0 -- White balance picker Off
OctaneMaxFPI.ViewportSetControlState 8 1 -- Align image
OctaneMaxFPI.ViewportSetControlState 9 1 -- lock resolution On
OctaneMaxFPI.ViewportSetControlState 9 0 -- lock resolution Off
OctaneMaxFPI.ViewportSetControlState 10 1 -- Region Render On
OctaneMaxFPI.ViewportSetControlState 10 0 -- Region Render Off
OctaneMaxFPI.ViewportSetControlState 11 1 -- Camera lock On
OctaneMaxFPI.ViewportSetControlState 11 0 -- Camera lock Off
OctaneMaxFPI.ViewportPickPixel 100 100 -- pick pixel (Focus or WB)
OctaneMaxFPI.ViewportGetControlState 12 -- get current pass ID
OctaneMaxFPI.ViewportSetControlState 12 0 -- set pass Beauty (0)
OctaneMaxFPI.ViewportSetControlState 12 1000 -- set pass Geometric normal (1000)
OctaneMaxFPI.ViewportSetControlState 13 1 -- Rebuild Scene
OctaneMaxFPI.OrbxLocalExport()
: export current scene as orbx, in current folder
OctaneMaxFPI.OctaneSceneClearAll()
OctaneMaxFPI.OctaneSceneClearGeometry()
OctaneMaxFPI.OctaneSceneClearMaterials()
: Clear current internal octane data for the scene. Once cleared, it will be rebuild on next render
---- Maxscript Interface Update from 10.18 ----
-Added global preference variables, to execute script before, after and during export:
PreExportScript
PostExportScript
ExportProgressScript
Added functions to OctaneMaxFPI interface [as displayed by 'showinterface OctaneMaxFPI'] :
<integer>OCMSetUserConfigValueBool <string>varName <boolean>varValue
<integer>OCMSetUserConfigValueInt <string>varName <integer>varValue
<integer>OCMSetUserConfigValueFloat <string>varName <float>varValue
<integer>OCMSetUserConfigValueString <string>varName <string>varValue
<integer>OCMGetUserConfigValueInt <string>varName
<boolean>OCMGetUserConfigValueBool <string>varName
<float>OCMGetUserConfigValueFloat <string>varName
<string>OCMGetUserConfigValueString <string>varName
The OCMGetUserConfigValueXXXX and OCMSetUserConfigValueXXXX functions allow access to the Octane Global preferences variables.
(The variable names can seen in 'octane3dsMaxConfig.cfg', that can be located by 'Explore User Settings folder' in the Tools menu of the Octane Global preferences.)
example: OctaneMaxFPI.OCMSetUserConfigValueBool "EnableOnTheFlyMaterialConversion" true
----- PROPERTIES:
Added properties to OctaneMaxFPI interface:
.orbxExportCurFrame : integer : Read
.orbxExportStatus : integer : Read
.orbxExportTextStatus : string : Read
.orbxExportFrameCount : integer : Read
.orbxExportStartCount : integer : Read|Write
--- Orbx export with MaxScript ---
format "\n--- Start of Orbx export : % current file:<%>, filePath: <%>---\n" "hello1" maxFileName maxFilePath
-- optionally overwrite some of the scene export settings :
rd = renderers.current
rd.exporter_pathType = 0 -- //0: UserDefinedFolder, 1:MaxFile folder, 2:StdSceneFolder, 3:StdExportFolder, 4:StdTempFolder,
rd.exporter_path = "c:/tmp"
rd.exporter_shortname = "testOut.orbx"
rd.exporter_useAnimation = 1
rd.exporter_startTime = 0 * 160 --frame 0 : in Ticks unit : 160 ticks per frame (at 30 frame per seconds..)
rd.exporter_endTime = 50 * 160 --frame 50
-- make sure the Octane viewport is closed before export (or else will only export current frame with Quick Export) :
OctaneMaxFPI.ViewportSetWindowState 0 -- close the Octane viewport
-- optionally set some script for checking export progress:
OctaneMaxFPI.OCMSetUserConfigValue "PreExportScript" "print \"Export started - hello2..\"\n"
OctaneMaxFPI.OCMSetUserConfigValue "ExportProgressScript" "format \"hello3 % \\n\"OctaneMaxFPI.orbxExportTextStatus"
OctaneMaxFPI.OCMSetUserConfigValue "PostExportScript" "format \"hello4 % \n\"OctaneMaxFPI.orbxExportTextStatus"
octVers = OctaneMaxFPI.OCMGetVersion()
if octVers >= 14000200 then
(
--new setting added in Octane Preferences / Export tab, from version 2023.1 - 14.02
OctaneMaxFPI.OCMSetUserConfigValueInt "ExportOrbxOverwriting" 1 --0:dialog, 1: Always overwrite, -1 : Never
)
-- Do the export --
OctaneMaxFPI.OrbxLocalExport() --will use exporter_shortname if viewport is not open (normal export), or a numbered filename for quick export
format "\n--- End of export report : % hello5---\n" OctaneMaxFPI.orbxExportTextStatus
-- read export status
OctaneMaxFPI.orbxExportTextStatus --eg "Export Finished"
OctaneMaxFPI.orbxExportStatus -- 0:Unknown, 1:started, 2:frame exported, 3:Finished normally 4:Failed
OctaneMaxFPI.orbxExportFrameCount
format "\n hello6: Status string <%>, status value: %, frame count : %\n" OctaneMaxFPI.orbxExportTextStatus OctaneMaxFPI.orbxExportStatus OctaneMaxFPI.orbxExportFrameCount
Here is this orbx export for the current scene as a .ms script:
Note that a confirmation dialog was added when exporting to an existing orbx file in recent versions.
This can be annoying when performing a batch export. In current and previous versions (14.01), you will need to delete those previous orbx files before exporting.
This will be fixed in the next release, with the addition of a preference setting 'ExportOrbxOverwriting' , as set in this script.
To export a single frame, use the standard slidertime maxscript function to set the frame before export, and disable animation export with renderers.current.exporter_useAnimation = 0
slidertime = 10
More commands may be added in the future, so the OCMGetVersion() should be used to check availability and compatibility of commands.