rfm2  22.0
A python-based rewrite of RenderMan for Maya
RenderMan_for_Maya Namespace Reference

Functions

def get_temp_logger (name)
 
def non_ascii_error (string, msg='RenderMan does not support non-ASCII characters:%r')
 
def non_ascii (string)
 
def find_module_file (version, mod_contents)
 
def save_module_file (fileContents, version)
 
def mod_file_contents (rfm_version, rfm_dir)
 
def write_module_file (rfm_version, rfm_dir)
 
def check_maya_module_file (rfm_version, rfm_dir)
 
def rfm_directory ()
 
def recursive_updater (in_dict, out_dict)
 
def read_config_file (fpath, config_dict)
 
def read_rfm_config (rfm_dir)
 
def add_rman_py_modules (additional_paths)
 
def find_nearest_RPS (rfm_env)
 
def set_rmantree (rfm_env)
 
def maya_version_check (version_list, rfm_version)
 
def read_buildid_file (rfm_dir)
 
def sanitize_path_list (path_list, build_vers, build_name)
 
def setup_environment ()
 
def maya_useNewAPI ()
 
def initializePlugin (mobject)
 
def uninitializePlugin (mobject)
 

Variables

 long = int
 
 BATCH_MODE = mc.about(batch=True)
 
string INDENT = ' ' * 50
 
 RFM_OS = platform.system()
 
string RFM_MODULE_NAME = 'RenderMan_for_Maya_%s'
 
string RFM_MOD_FILE = RFM_MODULE_NAME + '.mod'
 
string RFM_MOD_FILE_PATTERN = RFM_MODULE_NAME + '*.mod'
 
string RFM_MOD_TEMPLATE
 
string RFM_MOD_LINE_RE = r'\+\s+(?P<name>[\w\.]+)\s+(?P<version>[\d\.b]+)\s+(?P<dir>.+)'
 
dictionary DEFAULT_INSTALL_PATHS
 
 ex
 
 q
 
 address
 
 redirect_output
 
 timeout
 
 rsrc_path = os.path.join(rfm_directory(), 'rfm.rcc')
 

Detailed Description

This is the maya plugin file.
It will setup the execution environment, register nodes and commands, calling
other plugins if need be.

A module file will automaticaly be created if none can be found, unless the
RFM_DO_NOT_CREATE_MODULE_FILE environment variable is defined and set to 1.

## Node docs

A 'rfmDocsRoot' optionVar can be defined to point to a local RenderMan
documentation server. For example:

    import maya.cmds
    from rfm2.config import cfg
    desc = cfg().get_node_description_by_name('PxrBump')
    print desc.node_help_url('22')
    > https://rmanwiki.pixar.com/display/REN22/PxrBump

    maya.cmds.optionVar(sv=('rfmDocsRoot', 'http://sw/docs'))
    print desc.node_help_url('22', root=maya.cmds.optionVar(q='rfmDocsRoot'))
    > http://sw/docs/REN22/PxrBump

rfmDocsRoot can also define a file extension, separated by a pipe ("|") character:

    maya.cmds.optionVar(sv=('rfmDocsRoot', 'http://sw/docs|.html'))
    print desc.node_help_url('22', root=maya.cmds.optionVar(q='rfmDocsRoot'))
    > http://sw/docs/REN22/PxrBump.html

The URLs are registered at startup, so you will need to restart maya for any change
to take effect.

Function Documentation

◆ add_rman_py_modules()

def RenderMan_for_Maya.add_rman_py_modules (   additional_paths)
Add RMANTREE/bin and ice module to sys.path.

Args:
- addition_paths (str): a list of locations added to sys.path
+ Here is the caller graph for this function:

◆ check_maya_module_file()

def RenderMan_for_Maya.check_maya_module_file (   rfm_version,
  rfm_dir 
)
First, locate the rfm module file. If it doesn't exist, create one based on
what we already know.
We check the value of an optional RFM_DO_NOT_CREATE_MODULE_FILE environment
variable to skip module creation if need be.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_module_file()

def RenderMan_for_Maya.find_module_file (   version,
  mod_contents 
)
Find the module file and return its full path.

We rely on MAYA_MODULE_PATH to iterate through all directories likely
to contain our module file. We return None if we fail to locate it.
The module name contains the version number so we can have multiple
plugin versions showing up in Maya's plugin manager.

We can also have multiple mod files for the same version as long as they
point to different install paths and declare a different module name.

To facilitate version management, we allow users to rename their module file
by prefixing the version number with a number (typically a zero), so that it
is tested first and loaded.

Args:
- version (str): something like '22.0a1'

Returns:
- full path to the module file
+ Here is the caller graph for this function:

◆ find_nearest_RPS()

def RenderMan_for_Maya.find_nearest_RPS (   rfm_env)
Find a compatible RenderMan Pro Server directory in the same directory.

Args:
- rfm_env (dict): Dict built using rfm.json.

Returns:
- None if it failed to locate a compatible RPS directory.
- Full path to a compatible RPS directory if successful.
+ Here is the caller graph for this function:

◆ get_temp_logger()

def RenderMan_for_Maya.get_temp_logger (   name)
Create a temporary logger to output to the script editor. As soon as the
main logger is created, we switch to that one.

Args:
- name (str): the logger's name. Once a logger has been created under a
certain name, very call to logging.getLogger() will return that same
instance.

Returns:
- return the configured logger.

Raises:
- error_type: error_condition

◆ initializePlugin()

def RenderMan_for_Maya.initializePlugin (   mobject)
Initialize our plugin and register all nodes and commands.

◆ maya_useNewAPI()

def RenderMan_for_Maya.maya_useNewAPI ( )
The presence of this function tells Maya that the plugin produces, and
expects to be passed, objects created using the Maya Python API 2.0.

◆ maya_version_check()

def RenderMan_for_Maya.maya_version_check (   version_list,
  rfm_version 
)
Check if the current maya version is compatible with this plugin, based
on the version_list.

We use the short maya version (about -v), as Autodesk arbitrarily changed \
the format of `about -api`. In 2017, it returs 201700, in 2018 it became \
20180000.

Args:
- version_list (int list): a (potentialy unsorted) list of supported \
versions.
- rfm_version (str): The plugin's version. May contain alpha or beta \
identifiers.

Raises:
- RuntimeError: if the maya version is not compatible.
+ Here is the caller graph for this function:

◆ mod_file_contents()

def RenderMan_for_Maya.mod_file_contents (   rfm_version,
  rfm_dir 
)
+ Here is the caller graph for this function:

◆ non_ascii()

def RenderMan_for_Maya.non_ascii (   string)
+ Here is the caller graph for this function:

◆ non_ascii_error()

def RenderMan_for_Maya.non_ascii_error (   string,
  msg = 'RenderMan does not support non-ASCII characters: %r' 
)
+ Here is the caller graph for this function:

◆ read_buildid_file()

def RenderMan_for_Maya.read_buildid_file (   rfm_dir)
Read etc/buildid.text to get current build id. On failure, the 'name'
key will contain 'unknown'.

Args:
- rfm_dir (str): path to the rfm install directory.

Returns:
- A dict: {'version_major': 'xx', 'version_minor': 'x', 'beta': '',
           'day': 'unknown', 'month': 'unknown', 'date': 'xx',
           'year': 'xxxx', 'time': 'xx:xx:xx', 'id': 'xxxxxxxx',
           'name': 'unknown'}
+ Here is the caller graph for this function:

◆ read_config_file()

def RenderMan_for_Maya.read_config_file (   fpath,
  config_dict 
)
Read a json config file and update the config_dict with its contents.

Args:
- fpath (str): file path of the json file.
- config_dict (dict): the dict we will update with the file's contents.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_rfm_config()

def RenderMan_for_Maya.read_rfm_config (   rfm_dir)
Return a dict for all available rfm.json files.

rfm.json files describe the execution environment to the plugin. There are
4 locations to store them, checked in the following order:
- core: always rfm/config/rfm.json
- site: $RFM_SITE_CONFIG/config/rfm.json
- show: $RFM_SHOW_CONFIG/config/rfm.json
- shot: $RFM_SHOT_CONFIG/config/rfm.json
- user: ~/rfm/config/rfm.json

Args:
- rfm_dir (str): full path to the rfm directory.

Returns:
- a dict of category: filepath.

Raises:
- RuntimeError: if the core rfm.json file couldn't be located.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recursive_updater()

def RenderMan_for_Maya.recursive_updater (   in_dict,
  out_dict 
)
Recursively update a out_dict with in_dict.

WARNING: if you change this code, update rfm2/unit_tests/ut_rfm_json.py.

- dicts are recursively updated, i.e.:
  - new val will replace old val for the same key.
  - new key will be added if it doesn't exist in that dict.
- lists are merged, i.e.:
    - new list is prepended to old list.
      merge ['c'] in ['a', 'b'] -> ['c', 'a', 'b']
    - duplicates are removed while preserving the original order:
      merge ['c', 'd'] in ['a', 'b', 'c'] -> ['c', 'd', 'a', 'b']

Args:
- in_dict (dict): what will be merged in out_dict.
- out_dict (dict): the final output.

Returns:
- a dict.
+ Here is the caller graph for this function:

◆ rfm_directory()

def RenderMan_for_Maya.rfm_directory ( )
                                                        #

setup maya environment based on rfm.json # #

Returns the path to the rfm directory from which this plugin is executed.
+ Here is the caller graph for this function:

◆ sanitize_path_list()

def RenderMan_for_Maya.sanitize_path_list (   path_list,
  build_vers,
  build_name 
)
Remove renderman paths not matching the required build name and version.
+ Here is the caller graph for this function:

◆ save_module_file()

def RenderMan_for_Maya.save_module_file (   fileContents,
  version 
)
save the fileContents as a rfm module file.

first, we check if there is a pre-defined location for the current
platform. If it exists, save there.

Otherwise, we iterate through the list of maya module paths (as defined in
MAYA_MODULE_PATH), try to write the module file and return its path on
success. If the full path doesn't exist yet, we try to create it.
If writing the module failed, return None.

Args:
- fileContents (str): the contents of the module file

Returns:
- the full path to the newly created file.

Raises:
- error_type: error_condition
+ Here is the caller graph for this function:

◆ set_rmantree()

def RenderMan_for_Maya.set_rmantree (   rfm_env)
Set the environment variable based on the contents of the rfm.json
file(s).

Args:
- rfm_env (dict): the contents of (merged) rfm.json file(s).

Raises:
- RuntimeError: if the path is invalid.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setup_environment()

def RenderMan_for_Maya.setup_environment ( )
Read the rfm.json file(s) and updates a few environment variables.

We will at least load the core rfm.json and override it with other files
(if available). See read_rfm_config() for details.

We will update the following environment vars to make sure subsequent
initialisation steps succeed:
 - RFMTREE: validate the root directory of the plugin.
 - RMANTREE: validate the path to the correct version of the renderer.
 - PYTHONPATH: make sure the plugin's modules are available.

Returns:
- the dict created by the rfm.json file(s).

Raises:
- error_type: error_condition
+ Here is the call graph for this function:

◆ uninitializePlugin()

def RenderMan_for_Maya.uninitializePlugin (   mobject)
uninitialize the script plug-in

◆ write_module_file()

def RenderMan_for_Maya.write_module_file (   rfm_version,
  rfm_dir 
)
Creates the contents of the module file and writes it to the first writable
module path.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ address

RenderMan_for_Maya.address

◆ BATCH_MODE

RenderMan_for_Maya.BATCH_MODE = mc.about(batch=True)

◆ DEFAULT_INSTALL_PATHS

dictionary RenderMan_for_Maya.DEFAULT_INSTALL_PATHS
Initial value:
1 = {
2  'Darwin': {
3  'rfm': '/Applications/Pixar/RenderManForMaya-%s',
4  'rps': '/Applications/Pixar/RenderManProServer-%s'},
5  'Linux': {
6  'rfm': '/opt/pixar/RenderManForMaya-%s',
7  'rps': '/opt/pixar/RenderManProServer-%s'},
8  'Windows': {
9  'rfm': 'C:\\Program Files\\Pixar\\RenderManForMaya-%s',
10  'rps': 'C:\\Program Files\\Pixar\\RenderManProServer-%s'}
11 }

◆ ex

RenderMan_for_Maya.ex

◆ INDENT

string RenderMan_for_Maya.INDENT = ' ' * 50

◆ long

RenderMan_for_Maya.long = int

◆ q

RenderMan_for_Maya.q

◆ redirect_output

RenderMan_for_Maya.redirect_output

◆ RFM_MOD_FILE

string RenderMan_for_Maya.RFM_MOD_FILE = RFM_MODULE_NAME + '.mod'

◆ RFM_MOD_FILE_PATTERN

string RenderMan_for_Maya.RFM_MOD_FILE_PATTERN = RFM_MODULE_NAME + '*.mod'

◆ RFM_MOD_LINE_RE

string RenderMan_for_Maya.RFM_MOD_LINE_RE = r'\+\s+(?P<name>[\w\.]+)\s+(?P<version>[\d\.b]+)\s+(?P<dir>.+)'

◆ RFM_MOD_TEMPLATE

string RenderMan_for_Maya.RFM_MOD_TEMPLATE
Initial value:
1 = '''+ %(plugin_name)s %(version)s %(root)s
2 MAYA_PLUG_IN_PATH +:= plug-ins
3 '''

◆ RFM_MODULE_NAME

string RenderMan_for_Maya.RFM_MODULE_NAME = 'RenderMan_for_Maya_%s'

◆ RFM_OS

RenderMan_for_Maya.RFM_OS = platform.system()

◆ rsrc_path

RenderMan_for_Maya.rsrc_path = os.path.join(rfm_directory(), 'rfm.rcc')

◆ timeout

RenderMan_for_Maya.timeout