mari.examples

Contains example functionality implemented to demonstrate the use of the API.

Action Manager Examples.

mari.examples.action_manager.makeToolMenu()

Create a submenu containing all of the tool activation actions.

Asset Management Examples.

mari.examples.asset_management.aboutToProcessFactory(m)

Return a callback function that prints the path of the given image about to be processed.

mari.examples.asset_management.addAssetIDs()

Add made up asset management information to all objects in the scene.

mari.examples.asset_management.checkForUpdates()

Check for updates.

Iterates over all of the objects in the scene and pretends to check with a database to see if a later version is available.

mari.examples.asset_management.checkProjectAssetIDs()

Find the objects in this project and look for example metadata giving asset management version information.

mari.examples.asset_management.exportCallbackFactory(m)

Return a callback function that prints the export path of the given image.

mari.examples.asset_management.importCallbackFactory(m)

Return a callback function that prints the import path of the given image.

mari.examples.asset_management.installHooks()

Installs the example asset management hooks.

mari.examples.asset_management.installIOHooks()

Install I/O hooks.

Iterates over all channels and installs a hook that will be called when the images in that channel are exported and imported.

This can be used to do fun things like post export tex makes etc.

mari.examples.asset_management.managedAddVersion()

Return an example of a managed add geo version.

It loads a geometry object from file, tagging our asset IDs onto it. It shows that each version can be managed individually with metadata tagged onto objects.

mari.examples.asset_management.printExportPath(Image)

Print the export path, but could be used to perform a tex make etc.

mari.examples.asset_management.printImportPath(Image)

Print out the import path, but could also be used to perform a tex make.

mari.examples.asset_management.processingImage(Image)

Print the path of the image about to be processed, but could be used to perform a tex make etc.

C API channel export dialog example.

mari.examples.c_api_channel_export.onOKClicked(dialog, export_path, images, name, resolution, include_mipmaps)

Handle the OK button click event for the channel export dialog.

mari.examples.c_api_channel_export.showDialog()

Show the channel export dialog.

Camera Examples.

mari.examples.cameras.changeCurrentCameraOrthographic()

Change the current camera to orthographic.

mari.examples.cameras.changeCurrentCameraPerspective()

Change the current camera to perspective.

mari.examples.cameras.printAllCanvasesCameraInfo()

Print information about all the cameras.

mari.examples.cameras.printCameraInfo(camera)

Print information about a camera.

mari.examples.cameras.printCurrentCameraInfo()

Print information about the current camera.

Channel usage examples.

mari.examples.channels.getColorspacePrettyName(colorspace_config, stage)

Build a human-friendly color space name for a given color space and stage.

mari.examples.channels.linkCurrentChannels()

Link current channel changes on all objects for Mari.

For example, if you have two objects with the same channel names, changing the channel on one of them will change to the same channel on the other.

The signal is only triggered when the channel actually changes, so in this case there is no danger of an infinite loop of channels continuously changing.

mari.examples.channels.reimportCurrentPaintableLayer()

Link current channel changes on all objects for Mari.

mari.examples.channels.reimportImageSetPatches(imgset, patches)

Re-imports a list of given patches for a given imageset.

mari.examples.channels.showAllChannels()

Print information about all channels.

mari.examples.channels.showAllGeoPatchImageInfo()

Print information about all the geo/channels/patches/images combinations.

mari.examples.channels.showChannelInfo(channel)

Print information about an individual channel.

mari.examples.channels.showGeoPatchImageInfo(obj)

Print information about the patches of a geoentity.

mari.examples.channels.showLayerStackInfo(stack, indent_num_spaces=4)

Print information about the layers in a stack.

Channel usage examples.

mari.examples.colorspace.convertSelectedImages(ocio_config, output_colorspace)

Convert the currently selected images in the image manager to another colorspace.

This changes the underlying data in the image.

mari.examples.colorspace.disableRawOnChannels()

Disables the raw option on all channels, in all geometry, in the project.

mari.examples.colorspace.disableRawOnImages()

Disables the raw option on all images in the image manager.

mari.examples.colorspace.disableRawOnProject()

Disables all raw options in the project.

mari.examples.colorspace.disableRawOnProjectors()

Disables the raw option on all projectors in the project.

mari.examples.colorspace.enablePreColorspaceProject()

Enable color management on the project.

mari.examples.colorspace.getColorspacePrettyName(colorspace_config, stage)

Return a pretty name for the colorspace of a given stage in a colorspace config.

mari.examples.colorspace.registerOptimizedTransforms()

Register optimized GLSL shader transform code for ACES OCIO configs.

Registers optimized GLSL shader transform code for the ‘aces_1.0.3’, ‘aces_1.1’ and ‘aces_1.3’ OCIO configs. This method can not only significantly improve the performance within Mari but can also improve the accuracy of the transform itself due to the ability to remove the need for a LUT.

mari.examples.colorspace.showAllColorspaces()

Print all colorspace information in the project.

mari.examples.colorspace.showChannelInfo()

Print information about the colorspace of a channel.

mari.examples.colorspace.showColorspaceConfigInfo(colorspace_config, indent_num_spaces)

Print information about a colorspace config.

mari.examples.colorspace.showImageInfo()

Print information about the colorspace of all images in the image manager.

mari.examples.colorspace.showProjectInfo()

Print information about the global colorspaces of the project.

mari.examples.colorspace.showProjectorInfo()

Print information about the colorspace of all projectors in the project.

mari.examples.colorspace.switchColorspaceOnAll(ocio_config, from_colorspace, to_colorspace)

Switches all instances of a colorspace, within the project, to another.

This doesn’t change the underlying data but rather instructs Mari to now treat the data as being in new colorspace.

mari.examples.colorspace.switchColorspaceOnChannels(ocio_config, from_colorspace, to_colorspace)

Switches all instances of a colorspace to another on all channels, in all geometry, in the project.

mari.examples.colorspace.switchColorspaceOnConfig(colorspace_config, ocio_config, from_colorspace, to_colorspace)

Switches all instances of a colorspace to another in the colorspace config.

mari.examples.colorspace.switchColorspaceOnImages(ocio_config, from_colorspace, to_colorspace)

Switches all instances of a colorspace to another on all images in the image manager.

mari.examples.colorspace.switchColorspaceOnProject(ocio_config, from_colorspace, to_colorspace)

Switches all instances of a colorspace to another in the global defaults of the project.

mari.examples.colorspace.switchColorspaceOnProjectors(ocio_config, from_colorspace, to_colorspace)

Switches all instances of a colorspace to another on all projectors in the project.

Command port example.

class mari.examples.command_port.SendDialog

Bases: QDialog

Sends simple one-line text commands to Mari’s command port.

You can send commands to be executed in Mari to its command port, as long as you have it enabled in the settings and know the port number to use. Any Python command can be sent across using this method.

This example is just to demonstrate how to use the command port, and of course is not a great deal of use on its own.

Note

Make sure you terminate the commands to be send with a Ctrl+D character (ASCII code 4). This character instructs Mari to execute the received commands.

__init__()

Initialize this instance.

instance = None
sendCommand()

Send the command to Mari’s command port.

staticMetaObject = PySide6.QtCore.QMetaObject("SendDialog" inherits "QDialog": )
mari.examples.command_port.criticalError(msg)

Show a critical error message box.

mari.examples.command_port.showDialog()

Show the command port dialog.

Channel conversion dialog example.

mari.examples.convert_channel.onProjectClosed()

Disables the “Convert Channel” action when a project is closed.

mari.examples.convert_channel.onProjectOpened()

Enable the “Convert Channel” action when a project is opened.

mari.examples.convert_channel.show()

Show the channel conversion dialog.

Sample project creation function.

mari.examples.create_blacksmith_project.createBlacksmithProject()

Create a project using the BlackSmith assets from the web site.

At the time of writing, the assets for this script can be downloaded from: http://www.thefoundry.co.uk/products/mari/training/#blacksmith

The assets should be extracted from the zip files into a directory, which should end up looking like this:

  • Anvil

  • Apron

  • blacksmith

  • blacksmith_eyes

  • blacksmithObjects

  • Goggles

  • Hammer

  • Tongs

Please ensure the assets are set up correctly before running the script.

mari.examples.create_blacksmith_project.createImportChannelInfo(channel_name, channel_path, channel_template)

Create a Mari.ChannelInfo object for importing a channel.

mari.examples.create_blacksmith_project.importNewChannel(obj, channel_name, template)

Import a new channel into the given object.

mari.examples.create_blacksmith_project.loadObject(object_path, channel_import_list=None, channel_create_list=None)

Load an object into Mari with optional channel import and creation lists.

This is a sample script that demonstrates how to create a Mari project with a set of default options.

mari.examples.create_project.createAndImport()

Create a project with a set of default options, and import an image file.

mari.examples.create_project.createBasic()

Create a project with a set of default options.

Custom layer usage examples.

mari.examples.custom_layer.registerCustomAdjustmentLayer()

Register a custom adjustment layer from an XML file.

mari.examples.custom_layer.registerCustomProceduralLayer()

Register a custom procedural layer from an XML file.

Custom shader usage examples.

mari.examples.custom_shader.registerCustomDiffuseShader()

Register a custom diffuse shader.

mari.examples.custom_shader.registerCustomSpecularShader()

Register a custom specular shader.

mari.examples.custom_shader.registerCustomStandaloneShader()

Register a custom standalone shader.

Drag and drop callback examples.

mari.examples.drag_and_drop_callbacks.dragColorToNodeGraphDropCallback(mimeType, dropTarget, mimeData, contextualInfo)

Create a Basic/Color node in the Node Graph when a Mari color swatch is dragged into it.

Parameters:
  • mimeType (str) – Mime type of drop event

  • dropTarget (mari.Application.DropTargetArea) – Application area where drop event occurred

  • mimeData (QMimeData) – Mime data of drop event

  • contextualInfo (dict) – Contextual information of the application area where drop event occurred

This example shows how to create a dialog for exporting image sets from the current geo entity.

class mari.examples.export_dialog.DirBrowser(title='Folders')

Bases: QListWidget

Directory browser class.

__init__(title='Folders')

Initialize this instance.

addToLayout(layout)

Add the directory browser widget, plus a title, to the given layout.

getSelectedPaths()

Return a list of the absolute paths that are currently selected.

If nothing is selected, a list containing just the current path is returned. The returned list may still be empty if files are selected instead of directories.

onItemDoubleClicked(item)

Double-click an item to call this function.

staticMetaObject = PySide6.QtCore.QMetaObject("DirBrowser" inherits "QListWidget": )
updateContents()

Set the contents to the list of items in the current directory, and update the current folder display.

class mari.examples.export_dialog.FormatsBox(img_sets_widget, default_format='tif')

Bases: QComboBox

A combo box to display image export formats.

__init__(img_sets_widget, default_format='tif')

Initialize this instance.

staticMetaObject = PySide6.QtCore.QMetaObject("FormatsBox" inherits "QComboBox": )
updateFormats(default_format=None)

Update the list of formats based on the currently selected image sets.

class mari.examples.export_dialog.OpList(title='Operations')

Bases: QListWidget

Stores a list of operations to perform.

__init__(title='Operations')

Initialize this instance.

addOps(img_sets, dirs)

Return an operation from the current selections of image sets and directories.

addToLayout(layout)

Add the op list widget, plus a title, to the given layout.

ops()

Return a list of tuples of (image set, destination directory) export operations to perform.

removeOps()

Remove any currently selected operations.

staticMetaObject = PySide6.QtCore.QMetaObject("OpList" inherits "QListWidget": )
mari.examples.export_dialog.export(ops, format)

Apply the given export operations.

mari.examples.export_dialog.getPaintableImageSetLayerNamePairs(obj)

Return all the paintable image sets on a geo entity.

mari.examples.export_dialog.onOKClicked(dlg, ops, format)

Handle the OK button click event for the channel export dialog.

mari.examples.export_dialog.setBold(widget)

Set the given widget’s font to bold.

mari.examples.export_dialog.show()

Show the export image sets dialog.

This example shows how to create a dialog for exporting image sets from the current geo entity.

class mari.examples.export_shelf.ExportShelfDialog(default_path)

Bases: QDialog

Export shelf dialog class.

__init__(default_path)

Initialize this instance.

fillName(text)

Fill the name field with the selected shelf name.

getPath()

Return the full path for the export, combining the location and name fields.

getSelectedShelfName()

Return the name of the currently selected shelf, or an empty string if none is selected.

showPathDialog()

Show a dialog to select the export path.

staticMetaObject = PySide6.QtCore.QMetaObject("ExportShelfDialog" inherits "QDialog": )
mari.examples.export_shelf.run()

Run the export shelf dialog.

This example shows how to create a custom OCIO filter with user-configurable metadata.

class mari.examples.filters.OCIOFilterFactory

Bases: object

Factory class to create and manage a custom OCIO filter with user-configurable metadata.

__init__()

Initialize this instance.

cleanup()

Clean up the filter and filter collection.

createFilter()

Create and setup the OCIO filter with metadata for user configuration.

resolve_config_path(config_path)

Resolve the config path from a string or mari.FileList.

mari.examples.filters.cleanupCustomOcioFilter()

Clean up the custom OCIO filter.

mari.examples.filters.registerCustomOcioFilter()

Register the custom OCIO filter.

mari.examples.filters.resetAdjustmentLevelClampToDefault()

In 2.6.v3, we changed the default value of clamping on the adjustment level filter to Clamp.

This function parses through the objects->channels->layers to search for any level adjustment filter with a clamping value and reset it to its default ‘Disable’.

This example shows how to create a custom GLSL filter with user-configurable metadata.

class mari.examples.image_filters.NoiseFilterFactory

Bases: GLSLFilterFactory

Factory class to create and manage a custom noise filter with user-configurable metadata.

__init__()

Initialize this instance.

setupFilter(filter)

Set up the filter with metadata and GLSL code.

mari.examples.image_filters.generate_pixels()

Generate the pixel values for the noise texture.

The texture is a 256x256 RGBA texture where each pixel contains the x, y, z components of a gradient vector and a permuted index value. The gradient vectors are taken from Ken Perlin’s proposed gradients for 3D noise.

mari.examples.image_filters.registerAddNoiseFilter()

Register the Add Noise filter.

Example of duplicating a Layered Shader’s post-shader compisiting to create and control pre-shader blending.

class mari.examples.layered_channels_for_layered_shaders.UpdateChannelLayers(shader_parent)

Bases: object

Update channel layers.

This example class uses the supplied LayerShader’s post-shader compositing setup to update the used Channels to have matching pre-shader compositing. The layer arragment in the layered shader will be mirrored in each of the input channels. Rerunning the script will update as much of the used channels as possible.

This is a simple example and has the following limitations:

  • Layer Order

    The order of the top level layers in a channel must match the shader order in the layered shader. If you reorder the layers in channels things will fail.

  • Shader Order

    The order of the top level layers in a channel must match the shader order in the layered shader. If you reorder the shader layers in the layered shader things will fail. If a new shader layer is required add it to the bottom of the layer stack.

  • Changing Masks

    If you change a layer shader’s mask from a paintable to an mask stack the channel layers will not be updated. To resolve this, manually delete the masks from the channel layers.

  • Convert Paint Layer to Group Layer

    The script will use the layers that are already in the channels. If a layer is a paintable layer and it has already been assigned a mask and you would like it converted to a group do the following:

    • Create a group in the same place.

    • Drag the paintable layer into the group.

    • Remove the mask from the paitable layer.

    • Rerun the script.

To use this script, use the following basic steps:

  • Create a new project

  • Create a layered shader (click on the plus button on the shaders widget and choose “Layered”)

  • Go to the “Shader Layers” tab and create any 3 shaders (click on the plus button and choose from the list)

  • then run this script via Python > Shaders > Update Layered Channels

__init__(shader_parent)

Initialize this instance.

assignInputs()

Assign the common input channels to all the shaders.

collectInputs()

Collect all the inputs from the shaders and check for channel mismatches.

collectShaders()

Collect all the shaders and their masks from the layered shader.

createLayerGroups()

Create layer groups for all input channels, assigning shaders and masks.

createLayerGroups_SetMask(layer, mask)

Assign a mask to a layer, ensuring no conflicts with existing masks.

createLayerGroups_SetMaskStack(layer, mask)

Assign a mask stack to a layer, ensuring no conflicts with existing masks.

update()

Update the layer groups based on the current shaders and inputs.

mari.examples.layered_channels_for_layered_shaders.update()

Get the current object’s current layer shader and use it to control the pre-shader compisiting.

Example of creating set of pre-shader blended channels from a Layered Shader’s post-shader compisiting.

class mari.examples.layered_channels_from_layered_shaders.CreateChannelLayers(obj, shader_parent)

Bases: object

Create Channels from a Layered Shader’s post-shader compositing setup.

This example class uses the supplied LayerShader’s post-shader compositing setup to create Channels with matching pre-shader compositing. The shader’s and their inputs can be setup up with any variance of isolation or sharing. The created channels will be pre-shader composited versions of named shader inputs. The created channels can be used to do flattened exports for people that want a single pre-composited image for external rendering systems.

This is a simple example.

__init__(obj, shader_parent)

Initialize this instance.

collectInputs()

Collect all the input channels from the shaders.

collectShaders()

Collect all the shaders from the shader_parent’s input layer stacks.

createChannels()

Create channels for each of the shader inputs.

update()

Update the channels using the shader_parent’s post-shader compositing setup.

mari.examples.layered_channels_from_layered_shaders.update()

Get the current object’s current layer shader and use it to control the pre-shader compisiting.

This module contains some example functions to create and manipulate layers in Mari.

mari.examples.layers.createLayers()

Create some example channel and layers.

mari.examples.layers.createLayers_Channel(geo_index, geo_name, channel)

Create some example layers on a given channel and geoentity.

mari.examples.layers.createLayers_ImageSetClear(image_set, color)

Fill a layer (image set) with a given uniform color.

mari.examples.layers.printAdjustmentLayerInfo(header, layer)

Print info for an adjustment layer.

mari.examples.layers.printAdjustmentStackLayerHashes(header, layer, uv_index)

Print hash data for the adjustment stack for the given layer.

mari.examples.layers.printAdjustmentStackLayerInfo(header, layer)

Print info for an adjustment stack.

mari.examples.layers.printAllLayersHashes()

Print hash data for all the geoentities and channels within.

mari.examples.layers.printAllLayersInfo()

Print the hierarchy of the geoentity, its channels, and layers.

mari.examples.layers.printChannelLayerInfo(header, layer)

Print info for a channel.

mari.examples.layers.printGroupLayerHashes(header, layer, uv_index)

Print hash data for the group layer for the given layer.

mari.examples.layers.printGroupLayerInfo(header, layer)

Print info for a group layer.

mari.examples.layers.printImageInfo(header, image)

Print info for an image.

mari.examples.layers.printImageSetInfo(header, image_set)

Print info for an image set.

mari.examples.layers.printLayerHashes(header, layer, uv_index)

Print hash data for the given layer.

mari.examples.layers.printLayerInfo(header, layer)

Print info about a given layer.

mari.examples.layers.printMaskLayerInfo(header, layer)

Print info for the mask stack of the given layer.

mari.examples.layers.printMaskStackLayerHashes(header, layer, uv_index)

Print hash data for the mask stack for the given layer.

mari.examples.layers.printMaskStackLayerInfo(header, layer)

Print info for a mask stack.

mari.examples.layers.printPaintableLayerInfo(header, layer)

Print info for a paint layer.

mari.examples.layers.printProceduralLayerInfo(header, layer)

Print info about a procedural layer.

mari.examples.layers.printShaderLayerInfo(header, layer)

Print info for a shader layer.

mari.examples.layers.watchGeo(obj)

Add some key Qt signal connections on the given geoentity.

mari.examples.layers.watchLayer(obj)

Add some key Qt signal connections on the given layer.

This example shows how to create a tiled rgb layer with no premultiplied alpha .

mari.examples.layers_NPMA_tiled_RGB.createLayerNPMATiledRGB()

Create a tiled rgb layer with no premultiplied alpha .

This example shows how to disable all Layer’s “Amount Value” in the current project.

mari.examples.layers_disable_all_amount_values.changeChannels()

Change all channels in the current project to disable the ‘Amount Value’ for all layers.

mari.examples.layers_disable_all_amount_values.changeLayers(layers)

Disable the ‘Amount Value’ for all layers in the given list.

This example shows how to print information about lights and setup an environment light.

mari.examples.lights.moveToCameraPosition()

Print info about all the lights.

mari.examples.lights.printAllLightsInfo()

Print info about all the lights.

mari.examples.lights.printCurrentLightInfo()

Print info about the currently selected light.

mari.examples.lights.printEnvironmentLightInfo(light)

Print info about an environment light.

mari.examples.lights.printLightInfo(light)

Print info about the given light.

mari.examples.lights.printPointLightInfo(light)

Print info about a point light.

mari.examples.lights.registerActions()

Register actions with the action manager, and add them to a Python Menu.

mari.examples.lights.setupEnvironmentLightInfo()

Create an example environment light.

This example demonstrates copying and pasting of linked patches between ImageSets.

mari.examples.linked_patches.copyLinksFromCurrentImageSet()

Copy patch links from the current ImageSet.

mari.examples.linked_patches.getCurrentLinkedPatches()

Return the linked patches on the current ImageSet.

Returns:

Dictionary containing named groups of linked patches.

mari.examples.linked_patches.getMaximumResolution(images)

Return the maximum resolution of the list of input images.

Parameters:

images – List of images.

Returns:

QSize object containing the result.

mari.examples.linked_patches.lookupPatchesFromUdims(udims)

Return the patches associated with the input udims on the current geometry.

Invalid udims are skipped, but otherwise the list of patches is in the same order as the input list of udims.

Returns:

List of patches.

mari.examples.linked_patches.lookupUdimsFromPatches(patches)

Look up the udims for the input list of patches.

Returns:

List of udims for the input list of patches.

Trigger copying of patch link setup.

Trigger for pasting a previously copied patch links setup.

mari.examples.linked_patches.pasteLinksToCurrentImageSet()

Pastes patch links into the current ImageSet.

mari.examples.linked_patches.resizeImages(images, size)

Resizes the input list of images to the specified resolution.

Parameters:
  • images – List of images to resize.

  • size – QSize object specifying the desired resolution

mGo module.

mari.examples.mGo.getProjects(mayaHost, mGoPath)

Send the list of Mari projects to the Maya host machine.

mari.examples.mGo.importCAM(projectName, startTime, endTime, camFileName)

Import a CAM from Maya to Mari.

mari.examples.mGo.importGEO(sendMode, projectName, nameSpace, groups, FilePath, setR, sd, isAnim, startAnim, endAnim, myObjList, myFileName, meshData, sendShader, shadersOnly, shader_file)

Import a GEO from Maya to Mari.

mari.examples.mGo.printMessage(Str)

Print a message to the Python console and the Mari verbose log.

mari.examples.mGo.run_mGo()

Run the mGo toolkit UI.

Mari import and export Custom OpenGL Shaders.

mari.examples.mGo_Materialiser.importShader(myFileName, shader_file, sendMode)

Import a shader from the given file and apply it to the specified mesh.

mari.examples.mGo_Materialiser.runMaterialiser()

Run the mGo! Materialiser UI.

Custom Shortcuts for Mari mGo and to speed up the workflow with their custom shaders.

mari.examples.mGo_Shortcut_Actions.checkInputs(curShader, curChannel)

Check every input name and it’s content from the selected shader.

mari.examples.mGo_Shortcut_Actions.checkShader(curShader)

Check the current selected shader from the current selected Geo.

mari.examples.mGo_Shortcut_Actions.isolateCurrentShader()

Isolate the currently selected shader within a layered shader.

mari.examples.mGo_Shortcut_Actions.isolateReset()

Reset the visibility, blend mode, and blend amount of every shader in the layered shader.

mari.examples.mGo_Shortcut_Actions.mGoHelp()

Launch mGo documentation.

mari.examples.mGo_Shortcut_Actions.reload_mGo()

Reload the mGo module.

mari.examples.mGo_Shortcut_Actions.starts_mGo()

Launch the mGo palette.

mari.examples.mGo_Shortcut_Actions.syncChannels()

Synchronize all the channels.

Main function responsible in try to synchronize all the channels selected from all the geos in the project, based on the Input that has the current selected channel assign to it.

This example shows how to export layers from Mari to Maya.

class mari.examples.maya_export.LayersToExportList(title='For Export')

Bases: QListWidget

Stores a list of operations to perform.

__init__(title='For Export')

Initialize this instance.

addLayers(layer_list)

Add an operation from the current selections of layers and directories.

currentLayers()

Return a list of the currently selected layers.

removeLayers()

Remove any currently selected operations.

staticMetaObject = PySide6.QtCore.QMetaObject("LayersToExportList" inherits "QListWidget": )
class mari.examples.maya_export.ProgressDialog

Bases: QDialog

Dialog class to show the progress of the export process.

__init__()

Initialize this instance.

cancel()

Set the global variable to cancel the export.

instance = None
staticMetaObject = PySide6.QtCore.QMetaObject("ProgressDialog" inherits "QDialog": )
exception mari.examples.maya_export.UserCancelledException

Bases: Exception

Exception raised when the user cancels the export process.

mari.examples.maya_export.browseForFolder()

Show a dialog to select a folder for export.

mari.examples.maya_export.clickedOK(ui, layers_to_export_widget, eight_bit, higher_bit, force_overwrite_box)

Handle the OK button click event, initiating the export process.

mari.examples.maya_export.debugMsg(message)

Print a debug message to the Mari log if g_debug is True.

mari.examples.maya_export.export(ui, layers_to_export, dirname, eight_bit_fmt, higher_bit_fmt, force_overwrite_box)

Export the given layers to the specified directory.

mari.examples.maya_export.findParentLayerStack(layer, layer_stack)

Return the direct parent layer stack of the layer starting the search from the layer_stack.

mari.examples.maya_export.getMatchingLayers(layer_stack, criterionFn)

Return a list of all of the layers in the stack that match the given criterion function, including substacks.

mari.examples.maya_export.getPadding(num)

Calculate the U and V offsets based on a 4-digit number.

mari.examples.maya_export.getPaintableLayers(layer_stack)

Return a list of all of the paintable layers in the layer stack, including in substacks.

mari.examples.maya_export.getProceduralLayers(layer_stack)

Return a list of all procedural layers in the layer stack, including those in substacks.

mari.examples.maya_export.isProjectSuitable()

Check if the current project is suitable for exporting layers.

mari.examples.maya_export.makeBakedLayer(layer_to_bake)

Bake the passed layer.

mari.examples.maya_export.mayaGen(files_list, target_file_name, num_layers)

Generate the Maya scene based on the given files list, target file name, and number of layers.

mari.examples.maya_export.removeLayers(layers_to_remove)

Remove the passed layer.

mari.examples.maya_export.setBold(widget)

Set the font of the given widget to bold.

mari.examples.maya_export.showUI()

Show the main UI for the Mari to Maya export process.

mari.examples.maya_export.updateFilter(filter_box, layer_list)

For each item in the layer list display, set it to hidden iff it doesn’t match the filter text.

Nodegraph Examples.

mari.examples.nodes.addStreamMetadataToMcbp()

Add stream metadata to all the MultiChannelBakePoint nodes in the scene.

mari.examples.nodes.bakeSelectedBakePointNodes()

Bake selected bake point nodes in the root nodegraph of the currently selected geo.

mari.examples.nodes.printAllBakePointNodesInfo()

Print info about all the bake point nodes in the root nodegraph of the currently selected geo.

mari.examples.nodes.printAllNodesInfo()

Print info about all the nodes in the root nodegraph of the currently selected geo.

mari.examples.nodes.printNodeInfo(Node, Space, PrintAdvanced)

Print info about the given node.

mari.examples.nodes.printNodeTypes()

Print the types of nodes in the nodegraph.

mari.examples.nodes.printSelectedNodesInfo()

Print info about the currently selected nodes in the root nodegraph.

mari.examples.nodes.registerActions()

Register new actions with the action manager.

mari.examples.nodes.setupExampleNodegraph()

Create an example nodegraph.

Example: register analytical GLSL View Transforms for ACES 1.0.3 and ACES 1.1.

ACES 1.0.3 and 1.1 implement their default view transforms (sRGB and Rec.709) using a finite-domain Log2_48_nits shaper + 65x65x65 3D LUT pipeline. Scene-linear values above ~16.3 are clamped to the shaper boundary, collapsing all overexposed pixels to the same output colour and producing visible banding in HDR-lit viewports.

This script registers two additional entries in the View Transform dropdown for these configs:

  • sRGB (ACES) - Analytical

  • Rec.709 (ACES) - Analytical

These entries reproduce the full ACES RRT + ODT pipeline directly in GLSL with no domain limit. They are deliberately separate from the standard entries so that the default OCIO behaviour is preserved; users must explicitly opt in to the analytical path.

How to use this as a template for your own configs

To add a custom analytical view transform for your studio’s OCIO config:

Step 1 — Write a GLSL function:

vec4 my_view_transform(vec4 inVal) {
    vec3 c = inVal.rgb;
    // ... your transform here ...
    return vec4(c, inVal.a);
}

Step 2 — Define a config matcher. A string substring is the simplest option:

config_matcher = '/path/fragment/unique/to/my/config'

Or use a callable for more complex logic:

def config_matcher(config):
    return 'my_studio' in (config.getWorkingDir() or '')

Step 3 — Call registerAnalyticalViewTransform:

mari.ocio.registerAnalyticalViewTransform(
    config_matcher,
    display='MyDisplay',
    view='MyView',
    glsl_declaration=MY_GLSL_FUNCTION_STRING,
    func_name='my_view_transform',
)

Step 4 — Place your script in a location that is loaded at Mari startup (e.g. copy it into your studio startup scripts directory, or add it to this examples package).

mari.examples.ocio_aces_analytical_view.registerAcesAnalyticalViews()

Register analytical GLSL view transforms for ACES 1.0.3 and ACES 1.1.

Adds ‘sRGB (ACES) - Analytical’ and ‘Rec.709 (ACES) - Analytical’ to the View Transform dropdown when an ACES 1.0.3 or 1.1 config is active.

Testing and examples for the paint buffer API bindings.

mari.examples.paint_buffer.bitDepthAsString(depth)

Return a string representation of the paint buffer bit depth.

mari.examples.paint_buffer.drawSomePaint()

Create some contents for the paint buffer using the QT drawing code.

mari.examples.paint_buffer.getPaint(Label)

Return the contents of the paint buffer and show it in a dialog.

mari.examples.paint_buffer.paintBufferTest()

Create a dialog for testing the paint buffer API.

mari.examples.paint_buffer.resizeBuffer(size_combo, size_label)

Resizes the paint buffer based on the value in the combo box.

mari.examples.paint_buffer.setBold(widget)

Make the text in a widget bold.

mari.examples.paint_buffer.updateBuffer(depth_combo, depth_label)

Change the bit depth of the paint buffer based on the value in the combo box.

mari.examples.paint_buffer.updatePaint()

Update the contents of the paint buffer from a QImage.

mari.examples.paint_buffer.updateRotation(rot)

Update the rotation of the paint buffer based on the value of the given widget.

mari.examples.paint_buffer.updateScale(x, y)

Update the scale of the paint buffer based on the values of the given widgets.

mari.examples.paint_buffer.updateTranslate(x, y)

Update the translation of the paint buffer based on the values of the given widgets.

Post Process Filter Examples.

mari.examples.post_processing_filters.makeCustomLUT()

Create an example custom LUT for use with LUT post-processing filters.

Returns:

A list containing the LUT data.

mari.examples.post_processing_filters.makeTexture1D(width)

Create an example 1D texture for use with 1D post-processing filters.

Parameters:

width – Width of texture to create

Returns:

A list containing the 1D texture’s data.

mari.examples.post_processing_filters.makeTexture2D(width, height)

Create an example 2D texture for use with 2D post-processing filters.

Parameters:
  • width – Width of texture to create

  • height – Height of texture to create

Returns:

A list containing the 2D texture’s data.

mari.examples.post_processing_filters.makeTexture3D(width, height, depth)

Create an example 3D texture for use with 3D post-processing filters.

Parameters:
  • width – Width of 3D texture to create

  • height – Height of 3D texture to create

  • depth – Depth of 3D texture to create

Returns:

A list containing the 3D texture’s data.

mari.examples.post_processing_filters.makeTexture3DUpdate(width, height, depth)

Return a randomly generated 3D texture to demonstrate texture updating functionality.

Parameters:
  • width – Width of 3D texture to create

  • height – Height of 3D texture to create

  • depth – Depth of 3D texture to create

Returns:

A list containing the 3D texture’s data.

mari.examples.post_processing_filters.register1DPostFilter()

Create and register a post-processing filter.

This filter uses a 1D texture to do colour look-ups.

Returns:

Post-processing filter

mari.examples.post_processing_filters.register2DPostFilter()

Create and register a post-processing filter.

This filter uses a 2D texture to do colour look-ups.

Returns:

Post-processing filter

mari.examples.post_processing_filters.register3DPostFilter()

Create and register a post-processing filter.

This filter uses a 3D texture to do colour look-ups. It serves as an example of how one might implement 3D LUTs.

Returns:

Post-processing filter

mari.examples.post_processing_filters.registerCustomLUTPostFilter()

Create and register a post-processing filter.

This filter uses a custom LUT texture to do colour look-ups.

Returns:

Post-processing filter

mari.examples.post_processing_filters.registerFileLUTPostFilter()

Create and register a post-processing filter.

This filter uses a LUT texture from a file to do colour look-ups.

Returns:

Post-processing filter

mari.examples.post_processing_filters.restorePostFilterCollection()

Restore the post process filter collection to the one that was stored.

mari.examples.post_processing_filters.set1DPostFilter()

Register a 1D post-processing filter, and set it’s texture data.

mari.examples.post_processing_filters.set2DPostFilter()

Register a 2D post-processing filter, and set it’s texture data.

mari.examples.post_processing_filters.set3DPostFilter()

Register a 3D post-processing filter, and set it’s texture data.

mari.examples.post_processing_filters.setCustomLUTPostFilter()

Register a LUT post-processing filter, and set it’s file.

mari.examples.post_processing_filters.setFileLUTPostFilter()

Register a LUT post-processing filter, and set it’s file.

mari.examples.post_processing_filters.storePostFilterCollection()

Store the current post process filter collection so we can restore it at a later stage.

mari.examples.post_processing_filters.updatePostFilters()

Update the 3D texture for the example post-processing filter.

Projector Examples.

mari.examples.projectors.changeCurrentProjector()

Change the settings on the current projetor.

mari.examples.projectors.createProjector()

Create an example projector.

mari.examples.projectors.createTriplanarProjector()

Create an example triplanar projector.

mari.examples.projectors.printAllProjectorsInfo()

Print info about all the projetors.

mari.examples.projectors.printCurrentProjectorInfo()

Print info about the current projetor.

mari.examples.projectors.printProjectorInfo(projector)

Print info about given projetor.

This example demonstrates how to create a QML-based palette in Mari.

mari.examples.qml_palette.create_qml_palette()

Create or refresh the QML palette and bring it to the front.

Color analyzer example.

class mari.examples.register_which_transforms.ColorspaceAnalyzer(project)

Bases: object

Mari colorspace analyzer.

This class can be used to walk a project and analyze the colorspace configuration for it. Currently it has one feature whereby it figures out which colorspace transforms to register shader code for so that the project gets the benefit of the full GPU acceleration.

__init__(project)

Initialize this instance.

printAll()

Print all colorspace information in the project.

printChannelInfo()

Print the colorspace information of a channel.

printImageInfo()

Print the colorspace information of all images in the image manager.

printProjectInfo()

Print information about the global colorspaces of the project.

printProjectorInfo()

Print the colorspace information of all projectors in the project.

printShaderTransforms()

Print all required shader transforms to enable full GPU acceleration.

mari.examples.register_which_transforms.runColorspaceAnalyzer()

Run colorspace analyzer.

Analyzes the current projects Channel colorspace configs and prints out a template Python code block that can be used as a starting point to override CPU OCIO colorspace transforms with GPU accelerated GLSL versions.

Resource Info Examples.

mari.examples.resource_info.dumpResourceInfo()

Print some resource info.

mari.examples.resource_info.showAPIHelp()

Show the API documentation in a web browser.

mari.examples.resource_info.showCAPIHelp()

Show the C API documentation in a web browser.

mari.examples.resource_info.showCustomShaderAPIHelp()

Open the CustomShader API documentation in a web browser.

Selection Group Examples.

mari.examples.selection_groups.miscFunction(a)

Misc function that just prints a.

mari.examples.selection_groups.printSelectionGroupAndA(group, a)

Misc function that just prints info about a selection group and a.

mari.examples.selection_groups.printSelectionGroupInfo(selectionGroup)

Print information about a given selection group.

mari.examples.selection_groups.printSelectionGroupManagerInfo()

Grabs the selection group manager in the scene and print everything we can get from it.

mari.examples.selection_groups.registerActions()

Register new actions with the action manager, and add them to a Python Menu.

mari.examples.selection_groups.setupSignals()

Set up signals on the selection group manager.

Shader usage examples.

mari.examples.shaders.createShaders()

Create some example shaders.

mari.examples.shaders.printAllShadersInfo()

Print info about all the shaders.

mari.examples.shaders.watchGeo(obj)

Add some key Qt signal connections on the given geoentity.

ShaderStack usage examples.

mari.examples.shaderstacks.createShaderStacks()

Create some example shader stacks.

mari.examples.shaderstacks.createShaderStacks_ChannelDiffuse(obj, channel_name, color)

Create a diffuse channel.

mari.examples.shaderstacks.createShaderStacks_ChannelMask(obj)

Create a channel mask.

mari.examples.shaderstacks.createShaderStacks_ChannelShaderStack(obj)

Create a channel.

mari.examples.shaderstacks.createShaderStacks_ChannelShaderStack_AddShader(obj, channel_shaderstack, channel_diffuse)

Add a new shader to a shader stack.

Testing and examples for vector brushing.

mari.examples.vector_brush.addAction(identifier, command, icon_filename, tip, whats_this)

Add an action.

mari.examples.vector_brush.setupVectorBrush()

Set up the vector brush for painting.

Examples for creating a two channels ready for vector brushing.

mari.examples.vector_channel.createVectorChannels()

Create two channels ready for vector brushing.