scene module

Scene class and scene level utility functions.

List Open scenes

modo.scene.sceneList()[source]

Get a list of all the currently open scenes.

Returns:Collection of currently open scenes as modo.scene.Scene objects.
Return type:list

Scene Class

class modo.scene.Scene(scene=None)[source]

The main scene class.

Takes an optional lx.object.Scene object as an argument. If none is provided (the default) then the currently selected scene is used which will mostly be the general case. The module function sceneList() makes use of the scene parameter to return a list of open scenes as modo.scene.Scene objects.

Parameters:scene (lx.object.Scene) – Optional scene object to wrap.
actors

Returns a list of all actors in the scene

Getter:Returns a list of Actor objects found in this scene
Return type:list
addActor(name=None, items=None, makeActive=True)[source]

Add a new actor to the scene

Returns modo.item.Actor:
 

Actor item object

Parameters:
  • name (basestring) – optional name
  • items (list) – list of items for the actor to contain
addCamera(name=None)[source]

Add a new camera item to the scene

Returns:camera item
Return type:modo.item.Camera
Parameters:name (basestring) – optional name for the camera.
addGroup(name=None, gtype='')[source]

Add a new group item to the scene

Returns:

group item

Return type:

modo.item.Group

Parameters:
  • name (basestring) – optional name for the group item.
  • gtype (basestring) – optional group type, can be one of the default group types (‘assembly’, ‘actor’, ‘render’, ‘keyset’, ‘chanset’, ‘preset’, ‘shader’) or any other string to create a custom group type. Default is an empty string which creates a ‘Genera’ group type.
addItem(itype, name=None)[source]

Add a new item to the scene

Returns:

item

Return type:

modo.item.item

Parameters:
  • itype (modo.Constant) – item type
  • name (basestring) – optional name for the item.
Raises TypeError:
 

When failing

addJointLocator(name=None, parent=None)[source]

Adds a new joint to the scene

addMaterial(matType='advancedMaterial', name=None, index=None)[source]

Adds a new material to the scene

Parameters:
  • matType (modo.c.MATERIAL_*) – Type of material to create
  • name – Optional name for the material
Returns Item:

The material item

addMesh(name=None)[source]

Add a new mesh item to the scene

Returns:mesh item
Return type:modo.item.Mesh
Parameters:name (basestring) – optional name for the mesh.
addRenderPassGroup(name=None)[source]

Add a render pass group to the scene

Returns:render pass group.
Return type:modo.item.RenderPassGroup
Parameters:name (basestring) – optional name for the render pass group.
camera(cam)[source]

Returns a camera item in the scene. The supplied argument can be either a string (camera ID or name) or an integer (camera index in the scene’s collection of cameras)

Parameters:cam (basestring or int) – the camera
Returns:camera item
Return type:modo.item.Camera
cameraCount

Number of cameras in the scene.

Getter:Returns the number of camera items.
Return type:int
cameras

Returns a list of all the camera items in the scene as modo.item.Camera objects.

Getter:Returns a list of the camera items in the scene.
Return type:list of modo.item.Camera
currentRange

Set or read the current frame range start and end frame value should be passed in as a tuple.

Setter:Sets the range
Parameters:frange (tuple) – frame range - a tuple of ints (start, end).
Getter:Returns the start and end frames.
Return type:tuple
Raises ValueError:
 if supplied start frame is higher than end frame.
deselect(itemObj=None)[source]

Deselect an item.

Parameters:itemObj (basestring (item name or ID) or instance of either lx.object.Item or modo.item.Item) – the item to deselect. Clears the entire selection if None
duplicateItem(item, instance=False)[source]

Creates and returns a duplicate of the passed item

Returns item:Item
filename

File path of the scene.

Getter:Returns the file path of the scene or ‘None’ if not yet saved.
Return type:basestring or None
fps

Scene frames per second.

Note

There is no way to set the fps value from the Python API for any scene other than the currently selected one. Therefore, for any other scene the property will be read only and attempts to write to it will throw an AttributeError.


Getter:Returns the Frames Per Second
Return type:float
Setter:Sets the Frames Per Second
Parameters:fps (float) – Scene frames per second.
Raises:AttributeError
getGroups(gtype='')[source]

Returns all groups of the given kind

Parameters:gtype – optional group type, can be one of the default group types (‘assembly’, ‘actor’, ‘render’, ‘keyset’, ‘chanset’, ‘preset’, ‘shader’) or any other string to create a custom group type. Default is an empty string which creates a ‘Genera’ group type. You can also pass a list of multiple group types.
Returns list:List of groups matching the type
groups

Returns a list of all the group items in the scene as modo.item.Group objects.

Getter:Returns a list of the group items in the scene.
Return type:list of modo.item.Group
item(name)[source]

Look up item by name

Parameters:item (string) – Name to look for
Returns item:Found item
itemCount(itype)[source]

The number of items of a specified type in the scene.

Parameters:itype (int or basestring) – type of the items.
Returns:the number of items of the specified type in the scene.
Return type:int
items(itype=None, name=None, superType=True)[source]

List of items of the specified type in the scene.

Parameters:
  • itype – the item type.
  • name (basestring) – Optionally filter result by this text. Can use * and ? wildcards for globbing.
  • superType (bool) – If True, all items that have ‘itype’ as superType are listed. Else, only items of specifically that type are returned.
Returns:

list of the items of the specified type in the scene. If itype is None, all items in the scene are returned.

Return type:

list

iterItems(itype=None, name=None, superType=True)[source]

Same as items(), but returns a generator object.

iterItemsFast(itype)[source]

Stripped down alternative for the iterItems method to be used in large scenes where performance is crucial.

All objects are returned as type “Item” instead of being cast to specialized classes as in iterItems()

Parameters:itype – the item type. (i.e. lx.symbol.sITYPE_MESH)
Returns:Generator object with objects of type Item
Return type:generator
lightCount

Number of lights in the scene.

Getter:Returns the number of light items.
Return type:int
meshCount

Number of mesh items in the scene.

Getter:Returns the number of mesh items.
Return type:int
meshes

Returns a list of all the mesh items in the scene as modo.item.Mesh objects.

Getter:Returns a list of the mesh items in the scene.
Return type:list of modo.item.Mesh
name

Friendly name of the scene.

Getter:Returns the name of the scene.
Return type:basestring
removeItems(itm, children=False)[source]
Parameters:
  • Item – Item to remove from the scene
  • children (bool) – If True, all found children are deleted also
renderCamera

Get & set the scene’s current render camera

Setter:Set the scene’s current render camera
Parameters:camera (lx.object.Item of type ‘Camera’) – the camera item to set as the current render camera.
Getter:Returns the current render camera.
Return type:modo.Item.Camera
renderItem
Getter:Returns the first found render item of the scene
Return type:Item
renderPassGroups

Returns a list of all the render pass group items in the scene as modo.item.RenderPassGroup objects.

Getter:Returns a list of the render pass group items in the scene.
Return type:list of modo.item.Group
sceneItem

The scene’s ‘scene item’

Getter:Returns the scene’s scene item.
Return type:lxdt.item.Item (type lx.symbol.sITYPE_SCENE)
sceneRange

Set or read the scene’s frame range start and end frame value should be passed in as a tuple.

Setter:Sets the range
Parameters:frange (tuple) – frame range - a tuple of ints (start, end).
Getter:Returns the start and end frames.
Return type:tuple
Raises ValueError:
 if supplied start frame is higher than end frame.
select(itemObj, add=False)[source]
Parameters:
  • itemObj – the item to select.
  • add (bool) – whether to add to the current selection, False replaces the current selection.

Note:

To clear the selection of the scene, please use deselect() instead.
selected

Selected items in the scene.

Getter:Returns the selected items
Return type:list
selectedByType(itype, superType=False)[source]

Returns the selected items of a specific type as modo.item.Item objects.

Parameters:
  • itype (int or string) – item type to filter on.
  • superType (bool) – If True, all items derived fom itype are listed. Otherwise only items of the exact type of itype.
Returns:

selcted items of specified type.

Return type:

list of modo.item.Item