Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.trade.AbstractImporter class

Interface for importer plugins

Similarly to C++, importer plugins are loaded through ImporterManager:

>>> manager = trade.ImporterManager()
>>> importer = manager.load_and_instantiate('PngImporter')

Unlike C++, errors in both API usage and file parsing are reported by raising an exception. See particular function documentation for detailed behavior.

Methods

def close(self, /) -> None
Close currently opened file
def image1d(self, id: int, level: int = 0) -> ImageData1D
One-dimensional image
def image1d(self, name: str, level: int = 0) -> ImageData1D
One-dimensional image for given name
def image1d_for_name(self, name: str) -> int
One-dimensional image ID for given name
def image1d_level_count(self, id: int) -> int
One-dimensional image level count
def image1d_name(self, id: int) -> str
One-dimensional image name
def image2d(self, id: int, level: int = 0) -> ImageData2D
Two-dimensional image
def image2d(self, name: str, level: int = 0) -> ImageData2D
Two-dimensional image for given name
def image2d_for_name(self, name: str) -> int
Two-dimensional image ID for given name
def image2d_level_count(self, id: int) -> int
Two-dimensional image level count
def image2d_name(self, id: int) -> str
Two-dimensional image name
def image3d(self, id: int, level: int = 0) -> ImageData3D
Three-dimensional image
def image3d(self, name: str, level: int = 0) -> ImageData3D
Threee-dimensional image for given name
def image3d_for_name(self, name: str) -> int
Three-dimensional image ID for given name
def image3d_level_count(self, id: int) -> int
Three-dimensional image level count
def image3d_name(self, id: int) -> str
Three-dimensional image name
def material(self, id: int) -> MaterialData
Material
def material(self, name: str) -> MaterialData
Material for given name
def material_for_name(self, name: str) -> int
Material ID for given name
def material_name(self, id: int) -> str
Material name
def mesh(self, id: int, level: int = 0) -> MeshData
Mesh
def mesh(self, name: str, level: int = 0) -> MeshData
Mesh for given name
def mesh_attribute_for_name(self, name: str) -> typing.Optional[MeshAttribute]
Mesh attribute for given name
def mesh_attribute_name(self, name: MeshAttribute) -> typing.Optional[str]
String name for given custom mesh attribute
def mesh_for_name(self, name: str) -> int
Mesh ID for given name
def mesh_level_count(self, id: int) -> int
Mesh level count
def mesh_name(self, id: int) -> str
Mesh name
def object_for_name(self, name: str) -> int
Object ID for given name
def object_name(self, id: int) -> str
Scene name
def open_data(self, data: corrade.containers.ArrayView) -> None
Open raw data
def open_file(self, filename: str) -> None
Open a file
def scene(self, id: int) -> SceneData
Scene
def scene(self, name: str) -> SceneData
Scene for given name
def scene_field_for_name(self, name: str) -> typing.Optional[SceneField]
Scene field for given name
def scene_field_name(self, name: SceneField) -> typing.Optional[str]
String name for given custom scene field
def scene_for_name(self, name: str) -> int
Scene ID for given name
def scene_name(self, id: int) -> str
Scene name
def texture(self, id: int) -> TextureData
Texture
def texture(self, name: str) -> TextureData
Texture for given name
def texture_for_name(self, name: str) -> int
Texture ID for given name
def texture_name(self, id: int) -> str
Texture name

Properties

configuration: corrade.utility.ConfigurationGroup get
Plugin-specific configuration
default_scene: int get
Default scene
features: ImporterFeatures get
Features supported by this importer
flags: ImporterFlags get set
Importer flags
image1d_count: int get
One-dimensional image count
image2d_count: int get
Two-dimensional image count
image3d_count: int get
Three-dimensional image count
is_opened: bool get
Whether any file is opened
manager: object get
Manager owning this plugin instance
material_count: int get
Material count
mesh_count: int get
Mesh count
metadata: corrade.pluginmanager.PluginMetadata get
Plugin metadata
object_count: int get
Object count
plugin: str get
Plugin identifier string
scene_count: int get
Scene count
texture_count: int get
Texture count

Data

plugin_interface: str
Plugin interface string
plugin_metadata_suffix: str
Plugin metadata suffix
plugin_search_paths: typing.List[str]
Plugin search paths
plugin_suffix: str
Plugin suffix

Method documentation

def magnum.trade.AbstractImporter.image1d(self, id: int, level: int = 0) -> ImageData1D

One-dimensional image

Exceptions
AssertionError If no file is opened
RuntimeError If image import fails
IndexError If id is negative or not less than image1d_count
IndexError If level is negative or not less than image1d_level_count() for this image

def magnum.trade.AbstractImporter.image1d(self, name: str, level: int = 0) -> ImageData1D

One-dimensional image for given name

Exceptions
AssertionError If no file is opened
RuntimeError If image import fails
KeyError If name was not found
IndexError If level is negative or not less than image1d_level_count() for this image

def magnum.trade.AbstractImporter.image1d_for_name(self, name: str) -> int

One-dimensional image ID for given name

Exceptions
AssertionError If no file is opened

def magnum.trade.AbstractImporter.image1d_level_count(self, id: int) -> int

One-dimensional image level count

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than image1d_count

def magnum.trade.AbstractImporter.image1d_name(self, id: int) -> str

One-dimensional image name

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than image1d_count

def magnum.trade.AbstractImporter.image2d(self, id: int, level: int = 0) -> ImageData2D

Two-dimensional image

Exceptions
AssertionError If no file is opened
RuntimeError If image import fails
IndexError If id is negative or not less than image2d_count
IndexError If level is negative or not less than image2d_level_count() for this image

def magnum.trade.AbstractImporter.image2d(self, name: str, level: int = 0) -> ImageData2D

Two-dimensional image for given name

Exceptions
AssertionError If no file is opened
RuntimeError If image import fails
KeyError If name was not found
IndexError If level is negative or not less than image2d_level_count() for this image

def magnum.trade.AbstractImporter.image2d_for_name(self, name: str) -> int

Two-dimensional image ID for given name

Exceptions
AssertionError If no file is opened

def magnum.trade.AbstractImporter.image2d_level_count(self, id: int) -> int

Two-dimensional image level count

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than image2d_count

def magnum.trade.AbstractImporter.image2d_name(self, id: int) -> str

Two-dimensional image name

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than image2d_count

def magnum.trade.AbstractImporter.image3d(self, id: int, level: int = 0) -> ImageData3D

Three-dimensional image

Exceptions
AssertionError If no file is opened
RuntimeError If image import fails
IndexError If id is negative or not less than image3d_count
IndexError If level is negative or not less than image3d_level_count() for this image

def magnum.trade.AbstractImporter.image3d(self, name: str, level: int = 0) -> ImageData3D

Threee-dimensional image for given name

Exceptions
AssertionError If no file is opened
RuntimeError If image import fails
KeyError If name was not found
IndexError If level is negative or not less than image3d_level_count() for this image

def magnum.trade.AbstractImporter.image3d_for_name(self, name: str) -> int

Three-dimensional image ID for given name

Exceptions
AssertionError If no file is opened

def magnum.trade.AbstractImporter.image3d_level_count(self, id: int) -> int

Three-dimensional image level count

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than image3d_count

def magnum.trade.AbstractImporter.image3d_name(self, id: int) -> str

Three-dimensional image name

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than image3d_count

def magnum.trade.AbstractImporter.material(self, id: int) -> MaterialData

Material

Exceptions
AssertionError If no file is opened
RuntimeError If material import fails
IndexError If id is negative or not less than material_count

def magnum.trade.AbstractImporter.material(self, name: str) -> MaterialData

Material for given name

Exceptions
AssertionError If no file is opened
RuntimeError If material import fails
KeyError If name was not found

def magnum.trade.AbstractImporter.material_for_name(self, name: str) -> int

Material ID for given name

Exceptions
AssertionError If no file is opened

def magnum.trade.AbstractImporter.material_name(self, id: int) -> str

Material name

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than material_count

def magnum.trade.AbstractImporter.mesh(self, id: int, level: int = 0) -> MeshData

Mesh

Exceptions
AssertionError If no file is opened
RuntimeError If mesh import fails
IndexError If id is negative or not less than mesh_count
IndexError If level is negative or not less than mesh_level_count() for this mesh

def magnum.trade.AbstractImporter.mesh(self, name: str, level: int = 0) -> MeshData

Mesh for given name

Exceptions
AssertionError If no file is opened
RuntimeError If mesh import fails
KeyError If name was not found
IndexError If level is negative or not less than mesh_level_count() for this mesh

def magnum.trade.AbstractImporter.mesh_for_name(self, name: str) -> int

Mesh ID for given name

Exceptions
AssertionError If no file is opened

def magnum.trade.AbstractImporter.mesh_level_count(self, id: int) -> int

Mesh level count

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than mesh_count

def magnum.trade.AbstractImporter.mesh_name(self, id: int) -> str

Mesh name

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than mesh_count

def magnum.trade.AbstractImporter.object_for_name(self, name: str) -> int

Object ID for given name

Exceptions
AssertionError If no file is opened

def magnum.trade.AbstractImporter.object_name(self, id: int) -> str

Scene name

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than object_count

def magnum.trade.AbstractImporter.open_data(self, data: corrade.containers.ArrayView) -> None

Open raw data

Exceptions
AssertionError If trade.ImporterFeatures.OPEN_DATA is not supported
RuntimeError If file opening fails

def magnum.trade.AbstractImporter.open_file(self, filename: str) -> None

Open a file

Exceptions
RuntimeError If file opening fails

For compatibility with os.path, on Windows this function converts all backslashes in filename to forward slashes before passing it to Trade::AbstractImporter::openFile(), which expects forward slashes as directory separators on all platforms.

def magnum.trade.AbstractImporter.scene(self, id: int) -> SceneData

Scene

Exceptions
AssertionError If no file is opened
RuntimeError If scene import fails
IndexError If id is negative or not less than scene()

def magnum.trade.AbstractImporter.scene(self, name: str) -> SceneData

Scene for given name

Exceptions
AssertionError If no file is opened
RuntimeError If scene import fails
KeyError If name was not found

def magnum.trade.AbstractImporter.scene_for_name(self, name: str) -> int

Scene ID for given name

Exceptions
AssertionError If no file is opened

def magnum.trade.AbstractImporter.scene_name(self, id: int) -> str

Scene name

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than scene_count

def magnum.trade.AbstractImporter.texture(self, id: int) -> TextureData

Texture

Exceptions
AssertionError If no file is opened
RuntimeError If texture import fails
IndexError If id is negative or not less than texture_count

def magnum.trade.AbstractImporter.texture(self, name: str) -> TextureData

Texture for given name

Exceptions
AssertionError If no file is opened
RuntimeError If texture import fails
KeyError If name was not found

def magnum.trade.AbstractImporter.texture_for_name(self, name: str) -> int

Texture ID for given name

Exceptions
AssertionError If no file is opened

def magnum.trade.AbstractImporter.texture_name(self, id: int) -> str

Texture name

Exceptions
AssertionError If no file is opened
IndexError If id is negative or not less than texture_count

Property documentation

magnum.trade.AbstractImporter.default_scene: int get

Default scene

Exceptions
AssertionError If no file is opened

magnum.trade.AbstractImporter.image1d_count: int get

One-dimensional image count

Exceptions
AssertionError If no file is opened

magnum.trade.AbstractImporter.image2d_count: int get

Two-dimensional image count

Exceptions
AssertionError If no file is opened

magnum.trade.AbstractImporter.image3d_count: int get

Three-dimensional image count

Exceptions
AssertionError If no file is opened

magnum.trade.AbstractImporter.material_count: int get

Material count

Exceptions
AssertionError If no file is opened

magnum.trade.AbstractImporter.mesh_count: int get

Mesh count

Exceptions
AssertionError If no file is opened

magnum.trade.AbstractImporter.object_count: int get

Object count

Exceptions
AssertionError If no file is opened

magnum.trade.AbstractImporter.scene_count: int get

Scene count

Exceptions
AssertionError If no file is opened

magnum.trade.AbstractImporter.texture_count: int get

Texture count

Exceptions
AssertionError If no file is opened