rfm2  22.0
A python-based rewrite of RenderMan for Maya
 All Classes Namespaces Files Functions Variables Pages
RenderMan_for_Maya Namespace Reference

Functions

def get_logger
 
def find_module_file
 
                                                   #

Module management functions # # More...

 
def save_module_file
 
def mod_file_contents
 
def write_module_file
 
def check_maya_module_file
 
def rfm_directory
 
                                                        #

setup maya environment based on rfm.json # # More...

 
def recursive_updater
 
def read_config_file
 
def read_rfm_config
 
def add_rman_py_modules
 
def find_nearest_RPS
 
def set_rmantree
 
def maya_version_check
 
def read_buildid_file
 
def setup_environment
 
def maya_useNewAPI
 
def initializePlugin
 
def uninitializePlugin
 

Variables

string INDENT = ' '
 
tuple 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
 
dictionary DEFAULT_INSTALL_PATHS
 
tuple __log__ = get_logger('[rfm]')
 
int VERBOSE = 15
 
tuple VSC_REMOTE_DBG = mc.optionVar(q='rfmpydebug')
 
string HOST = 'localhost'
 
int PORT = 3000
 
tuple __rfm_env_config__ = setup_environment()
 
tuple __config__ = rfm2.config.init(__rfm_env_config__)
 
dictionary __mayaNodeClasses__ = {}
 
dictionary __mayaDrawOverrides__ = {}
 
dictionary __mayaShadingOverrides__ = {}
 

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.

Function Documentation

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:

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:

def RenderMan_for_Maya.find_module_file (   version,
  mod_contents 
)

                                                   #

Module management functions # #

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.

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

Returns:
- full path to the module file

+ Here is the caller graph for this function:

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:

def RenderMan_for_Maya.get_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
def RenderMan_for_Maya.initializePlugin (   mobject)
Initialize our plugin and register all nodes and commands.
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.
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:

def RenderMan_for_Maya.mod_file_contents (   rfm_version,
  rfm_dir 
)

+ Here is the caller graph for this function:

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:

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:

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
- 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:

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:

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:

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:

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:

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:

def RenderMan_for_Maya.uninitializePlugin (   mobject)
uninitialize the script plug-in
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

tuple RenderMan_for_Maya.__config__ = rfm2.config.init(__rfm_env_config__)
tuple RenderMan_for_Maya.__log__ = get_logger('[rfm]')
dictionary RenderMan_for_Maya.__mayaDrawOverrides__ = {}
dictionary RenderMan_for_Maya.__mayaNodeClasses__ = {}
dictionary RenderMan_for_Maya.__mayaShadingOverrides__ = {}
tuple RenderMan_for_Maya.__rfm_env_config__ = setup_environment()
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 }
string RenderMan_for_Maya.HOST = 'localhost'
string RenderMan_for_Maya.INDENT = ' '
int RenderMan_for_Maya.PORT = 3000
string RenderMan_for_Maya.RFM_MOD_FILE = RFM_MODULE_NAME+'.mod'
string RenderMan_for_Maya.RFM_MOD_FILE_PATTERN = RFM_MODULE_NAME+'*.mod'
string RenderMan_for_Maya.RFM_MOD_TEMPLATE
Initial value:
1 = '''+ %(plugin_name)s %(version)s %(root)s
2 MAYA_PLUG_IN_PATH +:= plugins
3 '''
string RenderMan_for_Maya.RFM_MODULE_NAME = 'RenderMan_for_Maya_%s'
tuple RenderMan_for_Maya.RFM_OS = platform.system()
int RenderMan_for_Maya.VERBOSE = 15
tuple RenderMan_for_Maya.VSC_REMOTE_DBG = mc.optionVar(q='rfmpydebug')