MaxScript usage with Octane 3dsMax

Forums: MaxScript usage with Octane 3dsMax
3D Studio Max Plugin (Export Script Plugins developed by [gk] and KilaD; Integrated Plugin developed by Karba)
Forum rules
Please post only in English in this subforum. For alternate language discussion please go here viewforum.php?f=18

MaxScript usage with Octane 3dsMax

Postby neonZorglub » Tue Jul 11, 2017 11:40 pm

neonZorglub Tue Jul 11, 2017 11:40 pm
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:
export_orbx_current.zip
(1.05 KiB) Downloaded 77 times


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.
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Re: MaxScript usage with Octane 3dsMax

Postby neonZorglub » Mon Aug 30, 2021 1:38 pm

neonZorglub Mon Aug 30, 2021 1:38 pm
Issues with "2D transformation" and "3D transformation" textures:

As the names of those textures starts with a number, we can't create them the same way as other textures.
The internal names of those textures has been changed since versions 6.32 and 10.16 to '_2D_transformation()' and '_3D_transformation().
(make sure the option 'Fix Non Standard internal class names' in Troubleshooting of Octane Preferences is enabled)

We can create those texture with:
tx = _2D_transformation()
tx = _3D_transformation()

(tx = 2D_transformation() gives: compile error: Bad number or time syntax..)

You can use
apropos("2D_transformation") to see the internal name _2D_transformation

showClass("2D_transformation") will show only 2D_transformation(2D transformation)
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Re: MaxScript usage with Octane 3dsMax

Postby neonZorglub » Wed Feb 16, 2022 10:03 pm

neonZorglub Wed Feb 16, 2022 10:03 pm
Access to kernel settings via standard maxscript:

renderers.current = Octane3dsmax () -- assign renderer to octane3dsmax

rd = renderers.current

Set the 'Max samples' :
rd.kernel_maxSamples = 1000

Display all render settings:
showproperties rd
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Re: MaxScript usage with Octane 3dsMax

Postby neonZorglub » Mon Sep 19, 2022 12:50 am

neonZorglub Mon Sep 19, 2022 12:50 am
Here is a sample to set properties of all textures of all selected objects's material:
(In this case, the Color Space)

Code: Select all


fn handleOctaneTexture sub_tex =
(
   -- is it an octane texture with a colorSpace property ?
   if (sub_tex.colorSpace != undefined) then (
      sub_tex.colorSpace = "_OctaneBuildIn_ACES2065_1"
)


fn handleMaterial mat =
(
   format(" Mtl:" + mat.name + "\n")
   -- parse sub-textures of this material
   orig_mtl = mat
   local sub_texs_count=getNumSubTexmaps orig_mtl
   if sub_texs_count>0 then (
      local sub_tex = undefined
      for i=1 to sub_texs_count do (
         sub_tex = getSubTexmap orig_mtl i
         if (sub_tex != undefined) then (
            format("texture name:\n" + sub_tex.name + "\n")
            handleOctaneTexture(sub_tex)
            )
         )
      )
   )         
   
)


fn handleSelectedObjects =
(
   for i = 1 to selection.count do
   (
      obj = selection[i]
      --format("obj name:\n" + obj.name + "\n\n")
      
      mat = obj.material
      if (mat != undefined) then
      (
         format("Obj name:" + obj.name + "  Mtl:" + mat.name + "\n")
         
         handleMaterial(mat)
         
         subMatCnt = getNumSubMtls mat
         if subMatCnt > 0 then
         (
            for i=1 to subMatCnt do
            (
               subMat = getSubMtl mat i
               if (subMat != undefined) then
               (
                  handleMaterial(subMat)
               )
            )   
         )
      )
   )
)

-- parse all materials of all selected objects :
handleSelectedObjects()




Note that the string to set the color space can be
"_OctaneBuildIn_OTHER" for 'Non-color data'
"_OctaneBuildIn_LINEAR_sRGB" for 'Linear sRGB + legacy gamma'
"_OctaneBuildIn_sRGB" for 'sRGB'
"_OctaneBuildIn_ACES2065_1" for 'ACES2065-1'
"_OctaneBuildIn_ACEScg" for 'ACEScg'

or any valid color space from the ocio file set in Octane Preferences, eg "compositing_log (Filmic Log Encoding)"
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Re: MaxScript usage with Octane 3dsMax

Postby neonZorglub » Wed Oct 05, 2022 12:33 am

neonZorglub Wed Oct 05, 2022 12:33 am
UPDATE: from version 2021.1.6 - 12.26 and 2022.1 XB3 - 13.07

Save and restore the Preferences

2 new functions have been added to the Octane maxscript functions to save and restore the Preferences:
OCMSavePreferenceFileAs and OCMRestorePreferenceFileFrom

The argument can be a full filename with absolute path, or a relative filename (no path).
A relative filename will use the same path as the preference file (octane3dsMaxConfig.cfg). It can be explored with Preferences menu Tools / Explore Octane Preferences Folder,
and is usually something like C:\Users\xxxx\AppData\Local\Autodesk\3dsMax\2023 - 64bit\ENU\plugcfg_ln

Examples:
OctaneMaxFPI.OCMSavePreferenceFileAs "octane3dsMaxCfg_myPreferences01.BAK"
OctaneMaxFPI.OCMSavePreferenceFileAs "c:/tmp/octane3dsMaxCfg_myPreferences01.BAK"

OCMRestorePreferenceFileFrom
OctaneMaxFPI.OCMRestorePreferenceFileFrom "octane3dsMaxCfg_myPreferences01.BAK"
OctaneMaxFPI.OCMRestorePreferenceFileFrom "c:/tmp/octane3dsMaxCfg_myPreferences01.BAK"

The Preference menu 'Preset' has a new 'Locked' preference, that can be saved and restored.
This allow to keep a safe copy of the Preferences, in case you changed too many settings and fail to render correctly.
This locked preference file is saved as 'octane3dsMaxCfg_Locked.BAK', and can be restored with OCMRestorePreferenceFileFrom:
OctaneMaxFPI.OCMRestorePreferenceFileFrom "octane3dsMaxCfg_Locked.BAK"


Another file 'octane3dsMaxCfg.BAK' is created when 3dsmax starts, as a copy of the current Preferences (octane3dsMaxConfig.cfg)
This allows you to restore it with 'Preset / Reset from startup settings'
This can also be restored with OCMRestorePreferenceFileFrom:
OctaneMaxFPI.OCMRestorePreferenceFileFrom "octane3dsMaxCfg.BAK"



MAXScript call on Octane Viewport pre/post open/close (Preferences / Viewport)

The Preferences / Viewport tab has 4 strings to call maxscript functions while opening / closing the Octane viewport:

This can be used to customize the render with Octane Viewport differently from normal render.
For example, to add a teapot on pre-open, and delete it on pre-close:
Pre Open Script:
myTP = teapot(); print "Hello-Pre-Open"
Pre Close Script:
delete myTP; print "Hello-Pre-Close"

Note that if the teapot is deleted in the Post-Close script, it is still visible in the 3dsmax viewport after closing the Octane Viewport.
A redraw seems to be missing at this point. The teapot disappear as soon as we select an object, or move the camera..
And none of the following functions seems to successfully redraw the viewport correctly : enableSceneRedraw(); redrawViews(); completeRedraw(); setNeedsRedraw();
So you may need to try to use the pre-Close or post-Close script for some functions...

As for all parameters of the preferences, those strings can be accessed from maxscript :
OctaneMaxFPI.OCMSetUserConfigValue "VP_PreOpen_script" "print \"hello PreOpen\""
OctaneMaxFPI.OCMSetUserConfigValue "VP_PostOpen_script" "print \"hello PostOpen\""
OctaneMaxFPI.OCMSetUserConfigValue "VP_PreClose_script" "print \"hello PreClose\""
OctaneMaxFPI.OCMSetUserConfigValue "VP_PostClose_script" "print \"hello PostClose\""


See also the pre export and post export script calls, with PreExportScript, PostExportScript.

Please note that those script strings are limited to 1024 characters, but you can call an external script if needed.
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Re: MaxScript usage with Octane 3dsMax

Postby neonZorglub » Mon Nov 21, 2022 9:14 pm

neonZorglub Mon Nov 21, 2022 9:14 pm
Accessing Octane Object Properties via Maxscript

The Octane Object properties are properties linked to 3dsMax Nodes, and can be accessed with the standard getUserProp and setUserProp
See for reference: https://help.autodesk.com/view/3DSMAX/2 ... 5BC0B9_htm

Note that when an octane property is set to its default value, it is not added to the User defined properties.

For example, if you set Object layer ID to 2 to an object,
in the 3dsMax 'Object properties', tab 'User Defined', you can see
octane_layer_ID = 2


Here is the list of current keys used by Octane objects, and their types:

BOOL "octane_movable_proxy";
BOOL "octane_object_motion_blur";
BOOL "octane_vertex_motion_blur";
INT "octane_motion_blur_samples";
INT "octane_layer_ID";
INT "octane_baking_group_ID";
BOOL "octane_dirt_visibility"
BOOL "octane_curvature_visibility"
INT "octane_velocity_channel_ID";
INT "octane_instance_ID";
INT "octane_light_mask";
INT "octane_custom_AOV_id";
INT "octane_custom_AOV_channel";
BOOL "octane_notif_obj_render";

Examples:
setUserProp $Box002 "octane_layer_ID" 3
setUserProp $Box002 "octane_movable_proxy" false

Notes:
Changing the settings while Octane object properties is open currently do not update the dialog.
You need to select another object, and then re-select the object that changed to see the new value

"octane_notif_obj_render" is only valid / visible when Kernel / Render Settings / Notify objects on render is set to 'Per Object'
"octane_light_mask" is a bit mask
Sun : 1
Environment : 2
light 1 : 4
light 2 : 8
light 3 : 16
..
light 8 : 512
For example, to set Sun and light 2, the value is 1 + 8 = 9
setUserProp $Box002 "octane_light_mask" 9
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Re: MaxScript usage with Octane 3dsMax

Postby neonZorglub » Thu Sep 07, 2023 11:54 pm

neonZorglub Thu Sep 07, 2023 11:54 pm
Get and Set any parameter by name and by parameter ID
(Available from version 2023.1 Beta3)

OctaneMaxFPI has new commands to get and set parameters by name and by parameter ID.
This can be useful as a work around, when parameter names conflict with other names while using the standard maxscript commands.

Use showinterface OctaneMaxFPI to view the updated command list and syntax.

---- Accessing parameters by name
Syntax detail for accessing a Float value:
<float>OCMGetParam_Float <maxObject>refTarget <string>param_name
<float>OCMSetParam_Float <maxObject>refTarget <string>param_name <float>value

The <maxObject> can be any 3dsMax object, node, material, texmap, etc.

example:
pw = OctaneMaxFPI.OCMGetParam_Float $OctaneLight_001 "Power"
is equivalent to
pw = $OctaneLight_001.Power

OctaneMaxFPI.OCMSetParam_Float $OctaneLight_001 "Power" 87.8
is equivalent to
$OctaneLight_001.Power = 87.8

Available commands with access by names are:
<integer>OCMGetParam_Int <maxObject>refTarget <string>param_name
<integer>OCMSetParam_Int <maxObject>refTarget <string>param_name <integer>value
<boolean>OCMGetParam_Bool <maxObject>refTarget <string>param_name
<boolean>OCMSetParam_Bool <maxObject>refTarget <string>param_name <boolean>value
<float>OCMGetParam_Float <maxObject>refTarget <string>param_name
<float>OCMSetParam_Float <maxObject>refTarget <string>param_name <float>value
<color>OCMGetParam_Color <maxObject>refTarget <string>param_name
<color>OCMSetParam_Color <maxObject>refTarget <string>param_name <color>value
<string>OCMGetParam_String <maxObject>refTarget <string>param_name
<string>OCMSetParam_String <maxObject>refTarget <string>param_name <string>value
<texturemap>OCMGetParam_Texmap <maxObject>refTarget <string>param_name
<texturemap>OCMSetParam_Texmap <maxObject>refTarget <string>param_name <texturemap>value

----- Using the parameter ID -----
The parameter ID is more likely to stay the same over time and version updates, unlike the name, that may change when issues are detected.


<integer>OCMShowParametersID <maxObject>mxObj

The return value is the number of parameter block(s) for this object.

This is similar to the standard 'showproperties' command, but gives the paramater ID's
Examples
OctaneMaxFPI.OCMShowParametersID $Box001
OctaneMaxFPI.OCMShowParametersID meditMaterials[1]
OctaneMaxFPI.OCMShowParametersID $


<integer>OCMGetParameterID <maxObject>mxObj <integer>blockIdx <string>param_name
power_pid = OctaneMaxFPI.OCMGetParameterID $OctaneLight_001 "Power"

Most basic parameter types are currently supported with those functions
OCMGetParameter_Int
OCMSetParameter_Int
OCMGetParameter_Bool
OCMSetParameter_Bool
OCMGetParameter_Float
OCMSetParameter_Float
OCMGetParameter_Color
OCMSetParameter_Color
OCMGetParameter_String
OCMSetParameter_String
OCMGetParameter_Texmap
OCMSetParameter_Texmap

The syntax is similar for all those functions:
<float>OCMGetParameter_Float <maxObject>mxObj <integer>blockIdx <integer>paramID
<float>OCMSetParameter_Float <maxObject>mxObj <integer>blockIdx <integer>paramID <float>value

The return value is the current value
The blockIdx is the index of the parameter block (starting at 0)

For example, create an Octane Light, then list all parameters IDs by typing
OctaneMaxFPI.OCMShowParametersID $OctaneLight_001
OctaneLight_001: OctaneLight, 1 PBlock(s)
"Enabled" ID: 0 type TYPE_BOOL
"target_mode" ID: 27 type TYPE_BOOL
...
"Power" ID: 3 type TYPE_FLOAT
...
"Cast_Shadows" ID: 14 type TYPE_BOOL

Take note of the parameter IDs that you want to access.
For example, the Power ID is 3, and the Cast_Shadows is 14.
The parameter block index is usually 0, but some objects (like the standard Bitmap) have several blocks.

Those can be read as follow
power = OctaneMaxFPI.OCMGetParameter_Float $OctaneLight_001 0 3
This is equivalent to
power = $OctaneLight_001.Power

cast_sh = OctaneMaxFPI.OCMGetParameter_Bool $OctaneLight_001 0 14
cast_sh = $OctaneLight_001.Cast_Shadows

and can be set as follow:
OctaneMaxFPI.OCMSetParameter_Float $OctaneLight_001 0 3 83.6
OctaneMaxFPI.OCMSetParameter_Bool $OctaneLight_001 0 14 false
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Render passes access from MaxScript

Postby neonZorglub » Thu Oct 12, 2023 3:13 am

neonZorglub Thu Oct 12, 2023 3:13 am
Update from version 2023.1 - 14.02

Added functions to access render passes of Octane Viewport and Render Elements.

This assume that the Viewport is set to multi-pass mode, either by setting Preferences/Viewport / 'Always enable Multi Passes', or by turning on the multi pass mode icon in the viewport.

---- Pass IDs -----
Render passes are identified by a unique ID. For example, the "Diffuse" pass has ID 3.
Get the pass ID from pass Name : OctaneMaxFPI.VPPassIdFromName
ex:
id = OctaneMaxFPI.VPPassIdFromName("Diffuse")
will return 3

Get the pass name from the ID:
ex:
passName = OctaneMaxFPI.VPGetPassName(3)
will return "Diffuse"


---- Viewport passes ----

Get the list of currently enabled passes:
lst = OctaneMaxFPI.VPGetPassList()

ex: return #(0, 43, 1007) for "Beauty", "Denoised beauty", and "Wireframe"

Notes:
The "Beauty" pass is always enabled.
The "Denoised beauty" is always in the list, even is the denoiser is not enabled.

The list can be manipulated with the standard maxscript operators
Ex:
append lst 1008

for p in lst do format "% %\n" p (OctaneMaxFPI.VPGetPassName(p))


Set the current pass list:

lst2 = #(4, 7, 33, 31, 1007)
OctaneMaxFPI.VPSetPassList(lst2)
OctaneMaxFPI.VPSetPassList(#(31,32)) -- set Noise and Shadow passes
OctaneMaxFPI.VPSetPassList(#()) -- clear all passes (only Beauty)

Add a pass:
OctaneMaxFPI.VPAddPass(1008)
OctaneMaxFPI.VPAddPass(OctaneMaxFPI.VPPassIdFromName("Wireframe"))

Remove a pass:
OctaneMaxFPI.VPRemovePass(1003)

Test if a pass is enabled:
isMaterialID_enabled = OctaneMaxFPI.VPHasPass(1004)

Get all existing passes:
allPasses = OctaneMaxFPI.VPGetFullPassList() -- get the 180 current passes available

for p in allPasses do format "%: %\n" p (OctaneMaxFPI.VPGetPassName(p))


----- Render elements passes -----

Get the list of passes set in Render Elements:
lst = OctaneMaxFPI.GetPassListFromRendElem()

Set the Render elements from a list:
OctaneMaxFPI.SetPassListToRendElem lst
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Re: MaxScript usage with Octane 3dsMax

Postby neonZorglub » Mon Oct 30, 2023 3:00 am

neonZorglub Mon Oct 30, 2023 3:00 am
From version 14.04, a new option is added in Preferences / Info menu : "List MaxScript usage reference"

This creates a text file with a list of all the Octane classes, and the syntax to create an instance.
This can be useful as some of the Octane classes can have names that differ from the display name, or conflict with the standard 3dsMax classes or other plugins classes.
The current octane class names are based on the Octane render node names, and some are unfortunately very common..
For example the Octane box projection texture is named 'Box', but this conflict with the 3dsMax object 'Box'.
In this case, 3dsMax renamed the Octane texture class as 'BoxtextureMap'

The list shows the Octane class name, the way(s) to create an instance.

If the 'display name' is different from the class name, this will also appear in the list.

Here are some examples:

'Flakes' , x = Flakes()

'Diffuse material' , x = Diffuse_material()
Note that 3dsMax replaces all special characters like space with an underscore (_)

'GSdf Box' , x = GSdf_Box() OR x = GeoSdfBoxObj(), display: 'GeoSdfBox'
Here, there is an additional creation name 'GeoSdfBoxObj'

'Camera' , x = cameracamera()
Here, the default name 'Camera' is not allowed by 3dsMax, so it has been renamed 'cameracamera'

'Box' , x = BoxtextureMap()
Here, 3dsMax added the suffix 'textureMap' to the base name 'Box'



Here is the current list:
OctaneMaxscriptDoc_v1404.txt
(33.79 KiB) Downloaded 58 times


For reference, here is the list of the version 2022.1.2 - 13.22 :
OctaneMaxscriptDoc_v1322.txt
(28.19 KiB) Downloaded 62 times



As new classes will be added in future versions, it is recommended to create the list on your machine for your version.
The creation tool (Preferences / Info menu : "List MaxScript usage reference") will open the containing folder to let you open the file.
For example, on 3dsMax 2024, it should be :
C:\Users\XXXXX\AppData\Local\Autodesk\3dsMax\2024 - 64bit\ENU\OctaneMaxscriptDoc_v1404.txt

Note that other plugins might also create classes with the same name as Octane, and in those cases, 3dsMax would rename one of the class.

If you have issues creating some octane classes, you can compare your local list with the list posted here. Any difference would indicate that 3dsMax renamed some class.


To maintain compatibility with older scripts, we can't change those names by default.
Some options will be added in the future to provide a better renaming scheme.

For classes using only one of the 2 creation names, we will add a more explicit name (like a 'Oct' prefix) in a future release.

Reminder:
Using 'classof' on an existing instance, you can get the class name usable with maxscript
ex: classof(meditMaterials[1]) or classof($teapot001.material) will display 'Diffuse_material'

Using 'showclass' with a class name will show the usable class name:
ex: showclass("Diffuse material") will display Diffuse_material(Diffuse material) : material {499252a7,78fd2b6c}

'showclass' can also help to see if a class may have a conflicting name:
ex: showclass("box")
Box : GeometryClass {10,0}
BoxtextureMap(Box) : textureMap {bb904d5,376b3497}
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Re: MaxScript usage with Octane 3dsMax

Postby neonZorglub » Mon Mar 18, 2024 10:28 pm

neonZorglub Mon Mar 18, 2024 10:28 pm
Update 2024-03-19
(from version 2023.1.2-14.11 and 2024.1 Alpha 3 - 15.05):

Compare AB
New functions and Actions added to control the new Image buffer comparator :
showinterface OctaneMaxFPI :
<integer>CmpABStore <integer>iSlot
<integer>CmpABSetCompare <integer>iSlot
<integer>CmpABGetCompare()
<integer>CmpABClearHistory()

Actions:
actionMan.executeAction 982383860 "6578" -- Octane: Store Render To History1
actionMan.executeAction 982383860 "6579" -- Octane: Store Render To History2
actionMan.executeAction 982383860 "6580" -- Octane: Store Render To History3
actionMan.executeAction 982383860 "6581" -- Octane: Store Render To History4
actionMan.executeAction 982383860 "6582" -- Octane: Compare Render To History1
actionMan.executeAction 982383860 "6583" -- Octane: Compare Render To History2
actionMan.executeAction 982383860 "6584" -- Octane: Compare Render To History3
actionMan.executeAction 982383860 "6585" -- Octane: Compare Render To History4
actionMan.executeAction 982383860 "6586" -- Octane: Compare: Stop
actionMan.executeAction 982383860 "6587" -- Octane: Compare: Left Right
actionMan.executeAction 982383860 "6588" -- Octane: Compare: Up Down
actionMan.executeAction 982383860 "6589" -- Octane: Compare: A B
actionMan.executeAction 982383860 "6590" -- Octane: Compare: B A

see related post: viewtopic.php?f=27&t=83256

AOV Preset
New functions added to write AOV preset scripts:

showinterface OctaneMaxFPI :
<integer>SetExchangeTexmap <integer>TexNum <texturemap>mxTex
<texturemap>GetExchangeTexmap <integer>TexNum
<integer>GetExchangeTexCount()

see related post: viewtopic.php?f=27&t=83255
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 896
Joined: Sun Jul 31, 2016 10:08 pm

Return to Autodesk 3Ds Max


Who is online

Users browsing this forum: No registered users and 12 guests

Tue Apr 16, 2024 4:22 am [ UTC ]