The parameter overrides on the Arnold Procedural object UI are stored in the BaseContainer between the id 10000 and 20000 with an offset of 100. The first override starts at 10000, the second at 10100, etc. The following IDs are used.

C4DAI_PROCEDURAL_PARAM_OVERRIDE_SELECTION = 10001
C4DAI_PROCEDURAL_PARAM_OVERRIDE_MODE = 10002

// Shader mode
C4DAI_PROCEDURAL_PARAM_OVERRIDE_SHADER = 10003
C4DAI_PROCEDURAL_PARAM_OVERRIDE_SHADER_USE_INDEX = 10010
C4DAI_PROCEDURAL_PARAM_OVERRIDE_SHADER_INDEX = 10004
// Expression mode
C4DAI_PROCEDURAL_PARAM_OVERRIDE_EXPRESSION = 10005
// Parameter mode
C4DAI_PROCEDURAL_PARAM_OVERRIDE_PARAM_NAME = 10006
C4DAI_PROCEDURAL_PARAM_OVERRIDE_COLOR_VALUE = 10007
C4DAI_PROCEDURAL_PARAM_OVERRIDE_FLOAT_VALUE = 10008
C4DAI_PROCEDURAL_PARAM_OVERRIDE_INT_VALUE = 10009
// Displacement mode
C4DAI_PROCEDURAL_PARAM_OVERRIDE_DISP_SHADER = 10011
C4DAI_PROCEDURAL_PARAM_OVERRIDE_DISP_SHADER_USE_INDEX = 10012
C4DAI_PROCEDURAL_PARAM_OVERRIDE_DISP_SHADER_INDEX = 10013
C4DAI_PROCEDURAL_PARAM_OVERRIDE_DISP_OVERRIDE_PARAMS = 10014
C4DAI_PROCEDURAL_PARAM_OVERRIDE_DISP_HEIGHT = 10015
C4DAI_PROCEDURAL_PARAM_OVERRIDE_DISP_PADDING = 10016
C4DAI_PROCEDURAL_PARAM_OVERRIDE_DISP_ZERO_VALUE = 10017
C4DAI_PROCEDURAL_PARAM_OVERRIDE_DISP_AUTOBUMP = 10018
// Subdivision mode
C4DAI_PROCEDURAL_PARAM_OVERRIDE_SUBDIV_TYPE = 10019
C4DAI_PROCEDURAL_PARAM_OVERRIDE_SUBDIV_ITERATIONS = 10020

 

Here's a simple script to list the Selection expression of all parameter overrides.

# parameter ids (from arnold_procedural.h)
C4DAI_PROCEDURAL_NUM_PARAM_OVERRIDES = 500
C4DAI_PROCEDURAL_PARAM_OVERRIDE_SELECTION = 10001
 
# find the Arnold Procedural object
proc = doc.SearchObject("Arnold Procedural")
 
# read the overrides
numParamOverrides = proc[C4DAI_PROCEDURAL_NUM_PARAM_OVERRIDES]
for i in range(numParamOverrides):
    offset = i * 100
    selection = proc[C4DAI_PROCEDURAL_PARAM_OVERRIDE_SELECTION + offset]
    print "%d. override Selection: %s" % (i+1, selection)


To add new overrides you just have to modify the BaseContainer of the object.

# parameter ids (from arnold_procedural.h)
C4DAI_PROCEDURAL_NUM_PARAM_OVERRIDES = 500
C4DAI_PROCEDURAL_PARAM_OVERRIDE_SELECTION = 10001
C4DAI_PROCEDURAL_PARAM_OVERRIDE_MODE = 10002
C4DAI_PROCEDURAL_PARAM_OVERRIDE_MODE__EXPR = 0
C4DAI_PROCEDURAL_PARAM_OVERRIDE_EXPRESSION = 10005

# find the Arnold Procedural object
proc = doc.SearchObject("Arnold Procedural")

# add a new Expression override
numParamOverrides = proc[C4DAI_PROCEDURAL_NUM_PARAM_OVERRIDES]
numParamOverrides += 1
proc[C4DAI_PROCEDURAL_NUM_PARAM_OVERRIDES] = numParamOverrides
offset = (numParamOverrides - 1) * 100
proc[C4DAI_PROCEDURAL_PARAM_OVERRIDE_SELECTION + offset] = "/MyObject"
proc[C4DAI_PROCEDURAL_PARAM_OVERRIDE_MODE + offset] = C4DAI_PROCEDURAL_PARAM_OVERRIDE_MODE__EXPR
proc[C4DAI_PROCEDURAL_PARAM_OVERRIDE_EXPRESSION + offset] = "base_color = (0.1, 0.7, 0.8)"
 
# update the scene
c4d.EventAdd()

 

Look at this script how to read and modify all types of parameter overrides.

  • No labels
© 2020-2021 Autodesk. All Rights Reserved / website terms / privacy/cookies / ccpa settings