mmSolver.tools.copypastecamera#

Tool to convert a Maya Camera (and Image Plane) into a file format readable by third-party software (for example, 3DEqualizer).

The aim is to make the tool similar to the Load Markers tool, allowing minimal set-up time for getting data between Maya and 3DEqualizer.

Tools#

The Copy/Paste Camera tool.

This tool will save the a camera and plate to a temporary file, for loading in third-party software (such as 3DEqualizer).

mmSolver.tools.copypastecamera.tool.main()#

Library#

The Copy/Paste Camera library functions.

The file saved will contain:

- Camera Name

- Image Plane File Path

- Pixel Aspect Ratio (static)

- Camera Translation (animated)

- Camera Rotation (animated - in ZXY rotation order)

- Camera Film Back (animated)

- Camera Film Offsets (animated)

- Camera Focal Length (animated)

This tool does not store Lens Distortion (the Image Plane File Path is assumed to be undistorted/flattened). A future version of this tool and file format may support lens distortion, if it were saved in Maya in a standardized way.

The JSON dictionary format:

{
    'version': int,
    'data': {
        'name': str,
        'start_frame': int,
        'end_frame': int,
        'image': {
            'file_path': str, # or None
            'width': int,     # or None
            'height': int,    # or None
            'pixel_aspect_ratio': float,  # or None
        },
        'attr': [
            str: [
                [int, float]
            ]
        ]
    }
}
mmSolver.tools.copypastecamera.lib.get_image_path_tokens(file_path)#

Split a file_path in the format of ‘file.1001.ext’ or ‘file_1001.ext’ into tokens.

The file_path can be a full path, not just a file name.

Returns:

A dictionary with keys ‘name’, ‘frame’ and ‘ext’, or None.

Return type:

dict or None

mmSolver.tools.copypastecamera.lib.get_image_path_single_frame(file_path, test_disk)#

Determine if the file_path is represents a single file, or not.

Parameters:
  • image_path (basestring) – The input image path to test.

  • test_disk (bool) – Should we access the disk to find files, or just test the string and assume the file exists?

Returns:

Image file path and boolean of whether the image path represents an image sequence, or not. Returns (None, None) if the function cannot determine the values accurately.

Return type:

(str, bool) or (None, None)

mmSolver.tools.copypastecamera.lib.get_image_path_multi_frame(image_path, test_disk)#

Determine if the given image_path represents multiple frames or not.

Parameters:
  • image_path (basestring) – The input image path to test.

  • test_disk (bool) – Should we access the disk to find multiple frames, or just test the string and assume the files exist?

Returns:

Image file path and boolean of whether the image path represents an image sequence, or not. Returns (None, None) if the function cannot determine the values accurately.

Return type:

(str, bool) or (None, None)

mmSolver.tools.copypastecamera.lib.get_image_path_pattern(image_name, use_frame_ext, test_disk=None)#

Compute the image path pattern, for the given Maya imagePlane path.

Assumptions:

- '#' character is not used in the image_name string.

- '?' character is not used in the image_name string.

- '*' character is not used in the image_name string.

- An animated image sequence uses the file naming pattern
  'file.####.ext' or 'file.ext', such as 'image.1001.jpg'
  or 'image.jpg'.

Note

If test_disk is True, this function will query the file path and directory on disk (not just string assumptions).

Parameters:
  • image_name (str) – Maya imagePlane file (sequence) path.

  • use_frame_ext (bool) – The value of imagePlane node’s ‘useFrameExtension’ attribute.

  • test_disk (bool) – Is this function allowed to query the file on disk and make calls to the disk? If not we use only string manipulation but do not test (for example) the actual file existence.

Returns:

Image file path and boolean of whether the image path represents an image sequence, or not. Returns (None, None) if the function cannot determine the values accurately.

Return type:

(str, bool) or (None, None)

mmSolver.tools.copypastecamera.lib.get_frame_range_from_file_pattern(file_path_pattern, fallback_range=None)#

Given a file pattern with ‘#’ characters representing the frame number, get the full frame range on disk.

Returns:

FrameRange

Return type:

FrameRange or (int, int)

mmSolver.tools.copypastecamera.lib.guess_pixel_aspect_ratio(cam_tfm, cam_shp, img_pl_shp, file_path_pattern)#

Given a camera node, image plane node and file path pattern try to guess the expected pixel aspect ratio.

Returns:

Pixel aspect ratio (PAR) for the camera, or None if none can be determined.

Return type:

float or None

mmSolver.tools.copypastecamera.lib.query_plate_data(cam_tfm, cam_shp, img_pl_shp, test_disk)#

Query plate information from the given camera and image plane.

Parameters:
  • cam_tfm (str) – Camera transform node of given image plane shape.

  • cam_shp (str) – Camera shape node of given image plane shape.

  • img_pl_shp (str) – Image Plane node shape node to query.

mmSolver.tools.copypastecamera.lib.query_camera_data(cam_tfm, cam_shp, frames, rotate_order, test_disk)#

Get the camera information from the given cameras

mmSolver.tools.copypastecamera.lib.generate(cam_data, plate_data, frame_range)#

Generate a JSON formatted string from the input data.

The generated string is then able to be saved to a file.

mmSolver.tools.copypastecamera.lib.write_temp_file(data_str)#

Write file.

Constants#

Contains constant values for the Copy/Paste Camera tool.