2.15. Project

2.15.1. Synopsis

2.15.1.1. Functions

2.15.1.2. Properties

2.15.2. Detailed Description

Main project class. Provides methods and properties for general project management of layers, groups, rendering and output directories.

class mocha.project.Project(detached_clip[, interlace_mode=NotInterlaced[, parent=NULL]])
Parameters
  • detached_clip (Clip) – Detached clip instance.

  • interlace_mode (InterlaceMode) – Interlace mode for creating clip.

  • parent (QObject) – Parent QObject or None.

Creates a new mocha project from existing clip.

class mocha.project.Project(project_file[, parent=NULL])
Parameters
  • project_file (str) – Path to mocha project file.

  • parent (QObject) – Parent QObject or None.

Opens existing mocha project.

Project.add_clip(detached_clip, clip_name)
Return type

Clip

Parameters
  • detached_clip (Clip) – Detached clip instance.

  • clip_name (str) – New clip name to register.

Creates a copy of detached_clip and add this to the project. Returns the copy.

Project.add_group([name=Project.tr( "New group" )[, layers=list()]])
Return type

LayerGroup

Parameters
  • name (str) – Name for creating group.

  • layers (list of Layer) – Layers which will be added to new group.

Creates and adds a new group of given layers. New group will get the new name.

Example:

>>> proj.add_group('new_group', (layer1, layer2))
<project.LayerGroup object at 0x25263b0>
Project.add_layer(clip[, name=Project.tr( "New layer" )[, frame_number=0[, view=0]]])
Return type

Layer

Parameters
  • clip (Clip) – Clip instance which will contain new layer.

  • name (str) – Name for creating layer.

  • frame_number (uint) – Number of frame where new layer is going to be added.

  • view_index – View index.

Returns

New Layer

Creates a new layer with name and attaches it to clip starting from frame_number.

Example:

>>> proj.add_layer(clip, 'new_layer')
<project.Layer object at 0x25263b0>
Project.export_rendered_shapes(layers, colorizeOutput, directory, extension, prefix, suffix, index_start, index_finish[, index_width=1[, views=list()[, separate_streams=false[, offset=0]]]])
Return type

Clip

Parameters
  • layers (list of Layer) – Layers which will be exported.

  • colorize_output – Colorize output option.

  • directory (str) – Output directory for rendered clip.

  • extension (str) – File extension for rendered clip.

  • prefix (str) – File prefix for rendered clip.

  • suffix (str) – File suffix for rendered clip.

  • index_start (uint) – Start frame number.

  • index_finish (uint) – Stop frame number.

  • index_width (uint) – Digits count in clip index.

  • views (list of View) – Views to export.

  • offset (uint) – Frame offset for the exported image sequence.

Exports matte clip to file system directory. This method represents mocha File - Export Rendered Shapes… dialog.

Project.find_groups(name)
Return type

list of LayerGroup

Parameters

name (str) – Group name for searching.

Returns all groups with the given name.

Project.find_layers(name)
Return type

list of Layer

Parameters

name (str) – Layer name for searching.

Returns all layers with the given name.

Project.get_output_dir()
Return type

str

Returns path to the current output directory.

Project.layer(layer_index)
Return type

Layer

Parameters

layer_index (uint) – Layer index.

Access a Layer by layer_index. Layers are indexed by their position in a flattened depth sorted list. If layer_index is out of range, layer() should return None.

Example:

>>> print len(proj.layers)
4
>>> print proj.layer(0)
<project.Layer object at 0x2514d40>
>>> print proj.layer(4)
None

See also:

Project.new_output_clip(input_clip, clip_name)
Return type

Clip

Parameters
  • input_clip (Clip) – Input clip instance.

  • clip_name (str) – New clip name to register.

Creates a new output clip.

Project.__ne__(rhs)
Return type

bool

Project.__eq__(rhs)
Return type

bool

Project.parameter(name_components)
Return type

Parameter

Parameters

name_components (list of strings) – Fully qualified name for a requested parameter.

Returns Parameter instance bound with given name path. The project instance is a root of the parameter system.

Project.parameter_set([name_components=list()])
Return type

ParameterSet

Parameters

name_components (list of strings) – Fully qualified name for a requested parameter set.

Returns ParameterSet instance bound with given name path. The project instance is a root of the parameter system. Pass an empty list [] to get access to the root.

Project.render(operation, start_index, stop_index[, layers=list()[, view=View(0)[, step=0]]])
Return type

Clip

Parameters
  • render_operation – instance of some render operation.

  • start_index (int) – Start frame number.

  • stop_index (int) – Stop frame number.

  • layers (list of Layer) – Layers to render.

  • views – Views to render.

  • step (int) – Step value.

Renders given render operation, e.g. RenderRemoveOperation.

Project.save()

Saves the project to a file with the name specified in the project_file property.

Project.save_as(file)
Parameters

file_name – Path to new project file.

Raise

RuntimeError - on failure.

Saves the project to a file with the given file_name. On success, changes the project_file property value to file_name value.

Project.set_output_dir(path[, validate=false])
Parameters
  • path (str) – Path to new output directory.

  • validate (bool) – validate given path.

Raise

AssertionError - if validate was set as True and path does not exist or is not writable.

Changes this project output directory.

Project.track_layers([start_index=0[, stop_index=UINT_MAX[, layers=list()[, views=list()]]]])
Parameters
  • start_index (uint) – Index of the first frame to track. If not passed, tracking starts from the beginning.

  • stop_index (uint) – Index of the last frame to track. If not passed, tracking processed till the end.

  • layers (list of Layer) – List of layers to track. If not passed, cogged and not locked layers are processed.

  • views (list of View) – List of views to track. If not passed, default views is processed.

Performs tracking process for the project.

Project.undo_group()
Return type

UndoGroup

Project.notes
Type

unicode

Access

read-write Provides access to project notes which are available via mocha View - Project Notes menu.

Example:

>>> proj.notes = "Foo"
>>> print proj.notes
Foo
Project.project_file
Type

unicode

Access

read-only Provides access to absolute project file path.

If the project wasn’t saved before, should return an empty string.

Example:

>>> print proj.project_file
/home/jc/Imagineer/mocha_projects/test_project.mocha
Project.clips
Type

dict of {unicode: Clip}

Access

read-only Provides access to dict of clip names and appropriate Clip’s.

Example:

>>> print proj.clips
{u'Ceremony': <project.Clip object at 0x1a30b90>, u'Logo': <project.Clip object at 0x25211b8>}
>>> print proj.clips['Ceremony']
'Ceremony' clip object
Project.in_out_range
Type

2-values tuple of long

Access

read-write Provides access to project in and out points.

Example:

>>> print proj.in_out_range
(0L, 6L)
>>> proj.in_out_range = (0, 5)
>>> print proj.in_out_range
(0L, 5L)
Project.frame_rate
Type

float

Access

read-write Provides access to project frame rate. Reflects mocha File - Project settings… - Frame rate.

Example:

>>> print proj.frame_rate
24.0
>>> proj.frame_rate = 30.0
>>> print proj.frame_rate
30.0
Project.interlace_mode
Type

InterlaceMode

Access

read-only Provides access to project interlace mode.

Example:

>>> print proj.interlace_mode
project.InterlaceMode.NotInterlaced
Project.layers
Type

list of Layer’s

Access

read-only Provides access to all project layers ordered from front to rear.

Example:

>>> print proj.layers
[<project.Layer object at 0x2522c68>, <project.Layer object at 0x2522cb0>, <project.Layer object at 0x2522d88>, <project.Layer object at 0x2522cf8>]
>>> print proj.layers[0].name
branch

See also:

Project.groups
Type

list of LayerGroup’s

Access

read-only Provides access to all project layers ordered from front to rear.

Example:

>>> print proj.groups
[<project.LayerGroup object at 0x42ab098>]
>>> print proj.groups[0].name
my group

See also:

Project.first_frame_offset
Type

int

Access

read-write Provides access to project first frame offset. Reflects mocha File - Project settings… - First frame offset.

Example:

>>> print proj.first_frame_offset
1
>>> proj.first_frame_offset = 3
>>> print proj.first_frame_offset
3
Project.length
Type

int

Access

read-write Provides access to project length. Reflects mocha File - Project settings… - Length (frames).

Example:

>>> print proj.length
7
>>> proj.length = 3
>>> print proj.length
3
Project.views
Type

list of ViewInfo’s

Access

read-write :raises RuntimeError: if trying to set stereo/multi-view project without appropriate license feature.

Raises

AssertionError – if names or abbreviations of given ViewInfo’s are not unique.

Provides access to project ViewInfo objects. It contains a single instance for mono projects and may contain more instances for stereo/multi-view ones. To make the project multi-view (if the active license allows), assign a list of several ViewInfo instances.

Example:

>>> print proj.views
[mocha.project.ViewInfo("mono", "M", (1, 0.3, 0.3))]
>>> proj.views = [ViewInfo('left', 'L', (0, 0, 0)), ViewInfo('right', 'R', (0, 0, 0))]
>>> print proj.views
[mocha.project.ViewInfo("left", "L", (0, 0, 0)), mocha.project.ViewInfo("right", "R", (0, 0, 0))]
Project.default_hero_view
Type

View

Access

read-write :raises: AssertionError – if the project does not contain a given view.

Provides access to project default hero view.

Example:

>>> print proj.default_hero_view
View(0)
>>> proj.default_hero_view = 0
>>> print proj.default_hero_view
View(0)
>>> proj.default_hero_view = 1
>>> print proj.default_hero_view
View(1)
>>> proj.default_hero_view = View(1)
>>> proj.default_hero_view
View(1)

See also:

Project.playback_in_point
Type

uint

Access

read-write Provides access to the valid project in point value.

Project.playback_out_point
Type

uint

Access

read-write Provides access to the valid project out point value.

Project.progress_watcher
Type

ProgressWatcher

Access

read-only Provides access to the current progress watcher object of exporting operations.

Project.default_trackable_clip
Type

Clip

Access

read-only Provides access to default trackable clip of the project.

Project.psets
Type

ParameterSet

Access

read-only Provides access to the root parameter set.

Mimics parameter_set() call.