AbcView 1.0.7

Module Contents

The AbcView Python API is divided into the IO and GL modules, widgets and utils.

App Module

abcview.app.create_app(files=None, first_frame=None, last_frame=None, current_frame=None, fps=24.0, script=None, bounds=False, mode=None, review=False, reset=False, verbose=False)[source]

Creates a new instance of an AbcView application.

Parameters:
  • files – list of files to load
  • first_frame – set first frame
  • last_frame – set last frame
  • current_frame – set current frame
  • fps – frames per second (default 24)
  • script – python script to load
  • bounds – force scene bounding box mode
  • mode – default object draw mode
  • review – use review settings
  • reset – reset layout settings
  • verbose – verbose standard out
Returns:

exit code

class abcview.app.AbcView(filepath=None)[source]

Main application. The best way to instantiate this class is to use the create_app() function.

clear(*args, **kwargs)[source]

Clears session and viewer.

confirm_close(message)[source]

Window close confirmation.

Parameters:message – text to display
find(*args, **kwargs)[source]

searches for objects in the tree matching name

get_selected()[source]

Returns the actively selected AbcView object.

handle_bad_scene(scene, frame)[source]

Undrawabe scene signal handler.

Parameters:scene – GLScene
handle_find(*args, **kwargs)[source]

handles input from the search box

handle_first_frame_change(frame)[source]

handles first frame change from time slider

Parameters:frame – frame number
handle_frame_all()[source]

Frame all.

handle_frame_object(item=None)[source]

Object level framing handler. Called when a user types ‘f’ while the object tree widget has focus.

Parameters:item – ObjectTreeWidgetItem
handle_frame_scene(item)[source]

Scene level framing handler.

Parameters:item – SceneTreeWidgetItem
handle_import(*args, **kwargs)[source]

File->Import menud handler

handle_item_loaded(*args, **kwargs)[source]

load checkbox click handler

Parameters:item – SceneTreeWidgetItem, SessionTreeWidgetItem
handle_item_selected(item)[source]

item click handler

Parameters:item – SceneTreeWidgetItem, SessionTreeWidgetItem
handle_item_unloaded(*args, **kwargs)[source]

Item unloaded handler.

Parameters:item – ObjectTreeWidgetItem
handle_last_frame_change(frame)[source]

handles last frame change from time slider

Parameters:frame – frame number
handle_new(*args, **kwargs)[source]

File->New menu handler

handle_new_camera(*args, **kwargs)[source]

handles adding a new camera to the session

Parameters:camera – GLCamera
handle_object_clicked(item)[source]

Object tree item clicked handler.

Parameters:item – ObjectTreeWidgetItem
handle_object_selected(*args, **kwargs)[source]

GLWidget object selected handler.

Parameters:name – name of object
handle_open(*args, **kwargs)[source]

File->Open menud handler

handle_play()[source]

Playback handler, starts playing the viewer.

handle_property_clicked(*args, **kwargs)[source]

Property tree item clicked handler.

Parameters:item – PropertyTreeWidgetItem
handle_reload(*args, **kwargs)[source]

File->Reload menu handler, reloads session

handle_scene_opened(scene)[source]

Scene open signal handler.

handle_scene_selected(scene)[source]

GLWidget scene selected handler.

Parameters:scene – GLScene
handle_set_camera(*args, **kwargs)[source]

handles setting the camera name on the session

Parameters:camera – GLCamera
handle_state_play_fwd()[source]

viewer state play foward signal handler

handle_state_play_stop()[source]

viewer state play stop signal handler

handle_stop()[source]

Viewer playback stop handler, stops the viewer playback.

handle_time_slider_change(frame)[source]

handles frame changes coming from time slider

Parameters:frame – frame number
handle_update_frame(frame)[source]

handles frame changes coming from viewer

handle_view_camera(*args, **kwargs)[source]

object tree ‘view through selected’ menu handler

Parameters:item – CameraTreeWidgetItem
import_file(filepath, overrides=None)[source]

File importer

Parameters:
  • filepath – file path to import, adds to session
  • overrides – parameter overrides dict
keyPressEvent(event)[source]

Handles key press events for the main application. If nothing matches, it defers to the viewer.

load_script(script)[source]

Loads and executes a python AbcView script.

Parameters:script – code or path to file containing python code.
load_settings()[source]

Loads AbcView layout settings from a PyQt settings file.

open_file(filepath)[source]

File loader

Parameters:filepath – file path to load, replaces session
reset_settings(width=550, height=500)[source]

Resets the AbcView layout settings to default values.

review_settings()[source]

Loads “review” display settings. Does not affect saved settings.

save_session(*args, **kwargs)[source]

Saves the current AbcView session to a given filepath, or to the current filepath if filepath is None.

Parameters:filepath – save to filepath (passing no args or None overrwrites current session file.
save_settings(settings=None)[source]

Saves layout settings to a PyQt settings file.

set_default_mode(mode)[source]

Sets the default display mode that overrides anything in the session file(s). Disable by setting mode to None.

Parameters:mode – alembic.io.Mode value, or None
set_frames_from_scene(scene)[source]

Updates the time slider’s frame range according to the min/max frames of the given scene.

Parameters:scene – GLScene object.
set_frames_from_session(session)[source]

Updates the time slider’s frame range according to the min/max frames of the given session.

Parameters:session – GLScene object.
set_load_files(filepaths)[source]

Sets the deferred load list. Loads files after the main window and event loop is up and running.

Parameters:
  • filepath – list of files to load
  • mode – Override display mode (abcview.io.Mode)
toggle_widget(*args, **kwargs)[source]

Toggles visibilty of given widget.

Parameters:widget – AbcView widget object.
abcview.app.io2gl(item, viewer=None)[source]

Recursively recasts an IO-module object to a GL-module object. Used for loading session items into the GL viewer.

Parameters:
  • item – Session, Scene, Camera or ICamera object
  • viewer – GLWidget object
abcview.app.version_check()[source]

Validates that alembic and alembicgl can be imported and that they meet the minimum requires versions.

Current minimum version requirements for Alembic are 1.5.0.

Returns:1 or 0

I/O Module

The IO module handles serialization and deserialization of the assembled scenes and sessions. The hierarchy structure basically consists of a top-level Session object that contains children items which can be either Scenes, Sessions, Cameras or ICAmeras. Each item in the hierarchy has a properties attribute for storing custom attributes. Only Scenes and ICameras reference Alembic archives.

Session hierarchy:

Session
    |- Properties
    |- Cameras
    `- Items
          `- Scene
               |- Properties
               `- file.abc

Sessions can also reference other session files.

class abcview.io.Scene(filepath=None)[source]

Represents a single item in an AbcView file (either .abc or .io file)

color

color to display in viewer

classmethod deserialize(data)[source]

Deserializes an Alembic scene from json data.

mode

GL polygon mode property

rotate

rotation property

scale

scale property

translate

translate property

class abcview.io.Session(filepath=None)[source]

AbcView API Session object. Top level container layer that holds properties and child session or scene objects.

De/serialization layer for AbcView sessions.

add_camera(camera)[source]
Param:GLCamera
add_file(filepath)[source]

Adds a filepath to the session

Parameters:filepath – path to file
add_item(item)[source]

Adds and item to the session

Parameters:item – Scene or Session object
cameras
is_dirty()[source]

Change that requires saving.

items

child items

load(filepath=None)[source]

Loads a session .io file.

merge(session)[source]

Merges a given session into this session.

Parameters:session – Session object to merge in
remove_camera(camera)[source]
Param:GLCamera
remove_item(item)[source]

Removes an item from the session

Parameters:item – Scene or Session object
save(filepath=None)[source]

Saves a session to a .io file.

serialize()[source]

Serializes the session object to a JSON dict.

set_camera(camera)[source]

Sets the “active” camera for a given session.

Param:GLCamera
walk()[source]

Recursive generator that yields Session, Scene and Camera objects. Adds a .session attribute to each item.

Yield:Session, Scene or Camera objects
class abcview.io.Camera(name, loaded=False)[source]

AbcView API Camera object. Camera attributes are not animatable as opposed to Alembic ICamera attributes.

Acting de/serialization layer for GLCamera objects.

class abcview.io.ICamera(icamera, loaded=False)[source]

Alembic ICamera de/serialization wrapper class. Use this class for loading Alembic ICameras.

Setting up a basic scene with a camera

# imports
>>> from abcview.io import Session, ICamera
>>> from abcview.utils import get_object

# create session, add scene file
>>> session = Session()
>>> session.add_file("scene.abc")

# add icamera wrapped in ICamera IO class
>>> session.add_camera(ICamera(get_object("shotcam.abc", 
                                          "ShotCam")
                               loaded=True))

# save session
>>> session.save("scene.io")
aspect_ratio(seconds=0)[source]

From Alembic/AbcGeom/CameraSample.h:

The amount the camera’s lens compresses the image horizontally (width / height aspect ratio)

name

Camera name

GL Module

When loading a Session object into the AbcView GUI, the IO objects are replaced with corresponding OpenGL objects from the GL module. The GL module classes provide GL-wrapped methods for viewing and manipulating Alembic scenes in AbcView GLViewer widgets.

class abcview.gl.GLCamera(viewer, name)[source]

Adds OpenGL methods to io.Camera objects.

Each Camera object contains a number of AbcOpenGL camera children, one for each GLWidget viewer object as a separate “view”. Each time a new view is added, a new AbcOpenGL GLCamera is added to the list of “views”, since each of these cameras may have a slightly different representation, for example the size of the camera corresponds to the viewer size.

aspect_ratio

aspect ratio

center

center of interest

far

get/set far clipping plane

fovx

get/set camera fov X

fovy

get/set camera fov Y

near

get/set near clipping plane

rotation

get/set rotation (imath.V3d)

scale

get/set scale (imath.V3d)

translation

get/set translation (imath.V3d)

class abcview.gl.GLICamera(viewer, camera)[source]

GL wrapper for ICamera objects

aspect_ratio

aspect ratio

center

center of interest

screen_window

screen window

class abcview.gl.GLScene(filepath)[source]

GL wrapper for Scene objects.

draw(visible_only=True, bounds_only=False)[source]

draws the scene

Parameters:
  • visible_only – drawing depends on visible property being set
  • bounds_only – draw object level bounding boxes only
draw_bounds(seconds=0, mode=GL_LINES)[source]

Draw scene-level bounding box for a given time in secs.

drawable()[source]

Returns True if this scene is drawable.

Widgets

class abcview.widget.tree_widget.AbcTreeWidgetItem(parent, object=None)[source]

Base class from which all other tree widgets are derived.

setText(name, value)[source]

setText override that looks up the tree column header index.

setToolTip(name, value)[source]

setToolTip override that looks up the tree column header index.

set_bad(bad)[source]

Set this tree widget item as being “bad” for some reason, e.g. an undrawable scene, with a visual indicator.

class abcview.widget.tree_widget.ArrayThread(parent, array, first=0, last=10)[source]

Simple Qthread that emits values from a (long) array. Takes a QWidget parent, an array and a max number of elements to emit as arguments (if max is None, get all of them).

first

array starting point

last

array ending point

class abcview.widget.tree_widget.SceneLineEditor(parent, name)[source]

Top-level delegate for SceneTreeWidgetItems, used on the name column to facilitate scene renaming.

class abcview.widget.viewer_widget.GLState(fps=24.0)[source]

Global GL viewer state manager. Manages list of Cameras and Scenes, which can be shared between viewers.

add_camera(camera)[source]

Adds a new GLCamera to the state.

Parameters:camera – GLCamera object
add_file(filepath)[source]

Generic add file method.

Parameters:filepath – path to file to add
add_scene(scene)[source]

Adds a scene to the viewer session.

Parameters:scene – GLScene object
cameras
clear()[source]

Clears the current state.

current_frame

set/get current frame

current_time

set/get current time

frame_count()[source]

Returns total frame count.

frame_range()[source]

Returns min/max frame range as a tuple.

get_camera(name)[source]

Returns a named camera for a given viewer.

Parameters:camera – GLCamera object
is_playing()[source]

Returns True if the playback timer is running.

max_frame

set/get maximum frame

max_time

set/get maximum time

min_frame

set/get minimum frame

min_time

set/get minimum time

play()[source]

Plays loaded scenes by activating timer and setting callback

remove_camera(camera)[source]

Removes a GLCamera object from the state.

Parameters:camera – GLCamera object
remove_scene(scene)[source]

Removes a given GLScene object from the master scene.

Parameters:scene – GLScene to remove.
scenes
stop()[source]

Stops scene playback

time_range()[source]

Returns min/max time range in seconds as a tuple.

class abcview.widget.viewer_widget.GLWidget(parent=None, state=None)[source]

AbcView OpenGL Widget.

Basic usage

>>> create_viewer_app("file.abc")

or inside a larger Qt application

>>> viewer = GLWidget()
>>> viewer.add_file("file.abc")
add_camera(camera)[source]
Parameters:camera – GLCamera object
add_file(filepath)[source]

Loads a given filepath into the GL viewer.

Parameters:filepath – path to Alembic file.
add_scene(scene)[source]

Adds a scene to the viewer session.

Parameters:scene – GLScene object
aspect_ratio()[source]

Returns current aspect ration of the viewer.

bounds

scene bounding box

clear()[source]

Resets this GL viewer widget, clears the shared state and creates a new default interactive camera.

frame(*args, **kwargs)[source]

Frames the viewer’s active camera on the bounds of the currently loaded and visible scenes.

Parameters:bounds – imath.Box3d bounds object.
handle_camera_action(action)[source]

New camera menu handler.

Parameters:action – QAction object
handle_set_camera(action)[source]

Sets camera from name derived from the text of a QAction.

Parameters:action – QAction
handle_set_mode(mode)[source]

Set active camera drawing mode.

Parameters:mode – abcview.io.Mode enum value
handle_state_change()[source]

State change signal handler.

keyPressEvent(*args, **kwargs)[source]

key press event handler

mouseDoubleClickEvent(event)[source]

mouse double-click event handler

mouseMoveEvent(*args, **kwargs)[source]

mouse move event handler

mousePressEvent(event)[source]

mouse press event handler

mouseReleaseEvent(event)[source]

mouse release event handler

paintGL()[source]

OpenGL painting override

remove_camera(camera)[source]
Parameters:camera – GLCamera object to remove
remove_scene(scene)[source]

Removes a given GLScene object from the master scene.

Parameters:scene – GLScene to remove.
selection(x, y)[source]

Bounding box selection handler. This handles selecting at the scene level, e.g. GLScenes. Object-level selection is handled in the AbcOpenGL lib.

Parameters:
  • x – mouse x position
  • y – mouse y position
Returns:

list of GLScene objects

set_camera(*args, **kwargs)[source]

Sets the scene camera from a given camera name string

Parameters:camera – Name of camera or GLCamera object
setup_default_camera()[source]

Creates the default interactive camera for this view (and others if the state is shared between viewers).

split(orientation=2, wipe=False)[source]

Splist the viewer into two separate widgets according to the orientation param.

QGroupBox
    `- QSplitter
            |- QGroupBox
            |       `- GLWidget
            `- QGroupBox
                    `- GLWidget
split_horz()[source]

Splits the viewer horizontally.

split_vert()[source]

Splits the viewer vertically.

unsplit()[source]

Unsplits and deletes current viewer

wheelEvent(*args, **kwargs)[source]

mouse wheel event handler

abcview.widget.viewer_widget.create_viewer_app(filepath=None)[source]

Creates a standalone viewer app.

>>> from abcview.widget.viewer_widget import create_viewer_app
>>> create_viewer_app("file.abc")
abcview.widget.viewer_widget.set_diffuse_light()[source]

Sets up the GL calls for the light that illuminates objects.

abcview.widget.viewer_widget.update_camera(func)[source]

GL camera update decorator

Utils

abcview.utils.find_objects(obj, name)[source]

Recursive generator function that yields objects with names matching given name regex.

Parameters:
  • obj – Alembic object
  • name – Name regular expression to match
Yeild:

Alembic object

abcview.utils.get_object(filepath, fullname)[source]

Returns an Alembic object from filepath matching the full path name fullname.

Parameters:
  • filepath – file path to archive
  • fullname – full path to the object
abcview.utils.get_schema_info(obj)[source]

Returns a tuple of the shema, title and base strings.

Example

>>> obj.getMetaData().serialize()
'schema=AbcGeom_Xform_v3;schemaObjTitle=AbcGeom_Xform_v3:.xform'

>>> get_schema_info(obj)
('AbcGeom_Xform_v3', 'AbcGeom_Xform_v3:.xform', None)
Parameters:obj – Alembic IObject.
Returns:Tuple of strings.
class abcview.utils.memoized(func)[source]

cache the return value of a method

This class is meant to be used as a decorator of methods. The return value from a given method invocation will be cached on the instance whose method was invoked. All arguments passed to a method decorated with memoize must be hashable.

If a memoized method is invoked directly on its class the result will not be cached. Instead the method will be invoked like a static method: class Obj(object):

@memoize def add_to(self, arg):

return self + arg

Obj.add_to(1) # not enough arguments Obj.add_to(1, 2) # returns 3, result is not cached