Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created June 16, 2021 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigRoy/d5e12f9fd682b97ce70a28d47a0536c4 to your computer and use it in GitHub Desktop.
Save BigRoy/d5e12f9fd682b97ce70a28d47a0536c4 to your computer and use it in GitHub Desktop.
Get custom attributes for each VRayRenderElement class type using vray "getAHint" similar to how V-Ray MEL procedure 'vrayAddRenderElementImpl' does it.
from maya import cmds
import itertools
def get_render_element_attributes(name):
"""Get attributes for VRayRenderElement based on class type"""
attrs = []
for i in itertools.count():
buffer = cmds.vray("getAHint",
"RenderElement",
name,
"attribute_%s" % i)
if not buffer:
break
attr = buffer[0]
attrs.append(attr)
return attrs
def get_render_element_attr_parameter(attr):
return cmds.vray("getAHint",
"RenderElementAttribute",
attr,
"vray_parameter")
# Example usage
for attr in get_render_element_attributes("ExtraTexElement"):
parameter = get_render_element_attr_parameter(attr)
print("{0: <45} - {1}".format(attr, parameter))
@BigRoy
Copy link
Author

BigRoy commented Jun 16, 2021

Usage:

for attr in get_render_element_attributes("ExtraTexElement"):
    parameter = get_render_element_attr_parameter(attr)
    print("{0: <45} - {1}".format(attr, parameter))

Example output:

vray_name_extratex                            - [u'name']
vray_type_extratex                            - [u'type']
vray_texture_extratex                         - [u'texmap']
vray_float_texture_extratex                   - [u'texmap_float']
vray_int_texture_extratex                     - [u'texmap_int']
vray_considerforaa_extratex                   - [u'consider_for_aa']
vray_filtering_extratex                       - [u'filtering']
vray_affectmattes_extratex                    - [u'affect_matte_objects']
vray_explicit_name_extratex                   - None
vray_exclude_list_extratex                    - [u'exclude_list']
vray_exclude_list_as_inclusive_extratex       - [u'exclude_list_as_inclusive_set']
vray_force_32_bit_output                      - [u'force_32_bit_output']
vray_denoise_extratex                         - [u'denoise']
vray_force_lossless_compression               - [u'force_lossless_compression']

To do the same for all V-Ray Render Elements class types:

from maya import mel

for class_type in mel.eval("vrayRenderElements"):
    print("Class Type: %s" % class_type)
    for attr in get_render_element_attributes(class_type):
        parameter = get_render_element_attr_parameter(attr)
        print("\t{0: <45} - {1}".format(attr, parameter))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment