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.MaterialData class

Material data

Attribute data access

The class makes use of Python’s dynamic nature and provides direct access to attribute data in their concrete types via attribute():

>>> material = importer.material(0)
>>> material.attribute(trade.MaterialAttribute.BASE_COLOR)
Vector(0.3, 0.4, 0.5, 0.8)
>>> material.attribute(trade.MaterialAttribute.DOUBLE_SIDED)
True

Methods

def attribute(self, layer: str, name: str) -> object
Value of a named attribute in a named material layer
def attribute(self, layer: str, name: MaterialAttribute) -> object
Value of a named attribute in a named material layer
def attribute(self, layer: str, id: int) -> object
Value of an attribute in a named material layer
def attribute(self, layer: MaterialLayer, name: str) -> object
Value of a named attribute in a named material layer
def attribute(self, layer: MaterialLayer, name: MaterialAttribute) -> object
Value of a named attribute in a named material layer
def attribute(self, layer: MaterialLayer, id: int) -> object
Value of an attribute in a named material layer
def attribute(self, layer: int, name: str) -> object
Value of a named attribute in given material layer
def attribute(self, layer: int, name: MaterialAttribute) -> object
Value of a named attribute in given material layer
def attribute(self, layer: int, id: int) -> object
Value of an attribute in given material layer
def attribute(self, name: str) -> object
Value of a named attribute in the base material
def attribute(self, name: MaterialAttribute) -> object
Value of a named attribute in the base material
def attribute(self, id: int) -> object
Value of an attribute in the base material
def attribute_count(self, layer: str) -> int
Attribute count in a named layer
def attribute_count(self, layer: MaterialLayer) -> int
Attribute count in a named layer
def attribute_count(self, layer: int) -> int
Attribute count in given layer
def attribute_count(self, /) -> int
Attribute count in the base material
def attribute_data_offset(self, layer: int) -> int
Offset of a layer inside attribute data
def attribute_id(self, layer: str, name: str) -> int
ID of a named attribute in a named material layer
def attribute_id(self, layer: str, name: MaterialAttribute) -> int
ID of a named attribute in a named material layer
def attribute_id(self, layer: MaterialLayer, name: str) -> int
ID of a named attribute in a named material layer
def attribute_id(self, layer: MaterialLayer, name: MaterialAttribute) -> int
ID of a named attribute in a named material layer
def attribute_id(self, layer: int, name: str) -> int
ID of a named attribute in given material layer
def attribute_id(self, layer: int, name: MaterialAttribute) -> int
ID of a named attribute in given material layer
def attribute_id(self, name: str) -> int
ID of a named attribute in the base material
def attribute_id(self, name: MaterialAttribute) -> int
ID of a named attribute in the base material
def attribute_name(self, layer: str, id: int) -> str
Name of an attribute in a named material layer
def attribute_name(self, layer: MaterialLayer, id: int) -> str
Name of an attribute in a named material layer
def attribute_name(self, layer: int, id: int) -> str
Name of an attribute in given material layer
def attribute_name(self, id: int) -> str
Name of an attribute in the base material
def attribute_type(self, layer: str, name: str) -> MaterialAttributeType
Type of a named attribute in a named material layer
def attribute_type(self, layer: str, name: MaterialAttribute) -> MaterialAttributeType
Type of a named attribute in a named material layer
def attribute_type(self, layer: str, id: int) -> MaterialAttributeType
Type of an attribute in a named material layer
def attribute_type(self, layer: MaterialLayer, name: str) -> MaterialAttributeType
Type of a named attribute in a named material layer
def attribute_type(self, layer: MaterialLayer, name: MaterialAttribute) -> MaterialAttributeType
Type of a named attribute in a named material layer
def attribute_type(self, layer: MaterialLayer, id: int) -> MaterialAttributeType
Type of an attribute in a named material layer
def attribute_type(self, layer: int, name: str) -> MaterialAttributeType
Type of a named attribute in given material layer
def attribute_type(self, layer: int, name: MaterialAttribute) -> MaterialAttributeType
Type of a named attribute in given material layer
def attribute_type(self, layer: int, id: int) -> MaterialAttributeType
Type of an attribute in given material layer
def attribute_type(self, name: str) -> MaterialAttributeType
Type of a named attribute in the base material
def attribute_type(self, name: MaterialAttribute) -> MaterialAttributeType
Type of a named attribute in the base material
def attribute_type(self, id: int) -> MaterialAttributeType
Type of an attribute in the base material
def has_attribute(self, layer: str, name: str) -> bool
Whether a named material layer has given attribute
def has_attribute(self, layer: str, name: MaterialAttribute) -> bool
Whether a named material layer has given attribute
def has_attribute(self, layer: MaterialLayer, name: str) -> bool
Whether a named material layer has given attribute
def has_attribute(self, layer: MaterialLayer, name: MaterialAttribute) -> bool
Whether a named material layer has given attribute
def has_attribute(self, layer: int, name: str) -> bool
Whether a material layer has given attribute
def has_attribute(self, layer: int, name: MaterialAttribute) -> bool
Whether a material layer has given attribute
def has_attribute(self, name: str) -> bool
Whether the base material has given attribute
def has_attribute(self, name: MaterialAttribute) -> bool
Whether the base material has given attribute
def has_layer(self, layer: str) -> bool
Whether a material has given named layer
def has_layer(self, layer: MaterialLayer) -> bool
Whether a material has given named layer
def layer_factor(self, layer: str) -> float
Factor of a named layer
def layer_factor(self, layer: MaterialLayer) -> float
Factor of a named layer
def layer_factor(self, layer: int) -> float
Factor of given layer
def layer_factor_texture(self, layer: str) -> int
Factor texture ID for a named layer
def layer_factor_texture(self, layer: MaterialLayer) -> int
Factor texture ID for a named layer
def layer_factor_texture(self, layer: int) -> int
Factor texture ID for given layer
def layer_factor_texture_coordinates(self, layer: str) -> int
Factor texture coordinate set for a named layer
def layer_factor_texture_coordinates(self, layer: MaterialLayer) -> int
Factor texture coordinate set for a named layer
def layer_factor_texture_coordinates(self, layer: int) -> int
Factor texture coordinate set for given layer
def layer_factor_texture_layer(self, layer: str) -> int
Factor array texture layer for a named layer
def layer_factor_texture_layer(self, layer: MaterialLayer) -> int
Factor array texture layer for a named layer
def layer_factor_texture_layer(self, layer: int) -> int
Factor array texture layer for given layer
def layer_factor_texture_matrix(self, layer: str) -> Matrix3
Factor texture coordinate transformation matrix for a named layer
def layer_factor_texture_matrix(self, layer: MaterialLayer) -> Matrix3
Factor texture coordinate transformation matrix for a named layer
def layer_factor_texture_matrix(self, layer: int) -> Matrix3
Factor texture coordinate transformation matrix for given layer
def layer_factor_texture_swizzle(self, layer: str) -> MaterialTextureSwizzle
Factor texture swizzle for a named layer
def layer_factor_texture_swizzle(self, layer: MaterialLayer) -> MaterialTextureSwizzle
Factor texture swizzle for a named layer
def layer_factor_texture_swizzle(self, layer: int) -> MaterialTextureSwizzle
Factor texture swizzle for given layer
def layer_id(self, layer: str) -> int
ID of a named layer
def layer_id(self, layer: MaterialLayer) -> int
ID of a named layer
def layer_name(self, layer: int) -> str
Layer name

Properties

alpha_mask: float get
Alpha mask
alpha_mode: MaterialAlphaMode get
Alpha mode
attribute_data_flags: DataFlags get
Attribute data flags
is_double_sided: bool get
Whether a material is double-sided
layer_count: int get
Layer count
layer_data_flags: DataFlags get
Layer data flags
types: MaterialTypes get
Material types

Method documentation

def magnum.trade.MaterialData.attribute(self, layer: str, name: str) -> object

Value of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute(self, layer: str, name: MaterialAttribute) -> object

Value of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute(self, layer: str, id: int) -> object

Value of an attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute(self, layer: MaterialLayer, name: str) -> object

Value of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute(self, layer: MaterialLayer, name: MaterialAttribute) -> object

Value of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute(self, layer: MaterialLayer, id: int) -> object

Value of an attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute(self, layer: int, name: str) -> object

Value of a named attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute(self, layer: int, name: MaterialAttribute) -> object

Value of a named attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute(self, layer: int, id: int) -> object

Value of an attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute(self, name: str) -> object

Value of a named attribute in the base material

Exceptions
KeyError If name isn’t present in the base material

def magnum.trade.MaterialData.attribute(self, name: MaterialAttribute) -> object

Value of a named attribute in the base material

Exceptions
KeyError If name isn’t present in the base material

def magnum.trade.MaterialData.attribute(self, id: int) -> object

Value of an attribute in the base material

Exceptions
IndexError If id is negative or not less than attribute_count()

def magnum.trade.MaterialData.attribute_count(self, layer: str) -> int

Attribute count in a named layer

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.attribute_count(self, layer: MaterialLayer) -> int

Attribute count in a named layer

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.attribute_count(self, layer: int) -> int

Attribute count in given layer

Exceptions
IndexError If layer is negative or not less than layer_count

def magnum.trade.MaterialData.attribute_data_offset(self, layer: int) -> int

Offset of a layer inside attribute data

Exceptions
IndexError If layer is negative or greater than layer_count

def magnum.trade.MaterialData.attribute_id(self, layer: str, name: str) -> int

ID of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_id(self, layer: str, name: MaterialAttribute) -> int

ID of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_id(self, layer: MaterialLayer, name: str) -> int

ID of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_id(self, layer: MaterialLayer, name: MaterialAttribute) -> int

ID of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_id(self, layer: int, name: str) -> int

ID of a named attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_id(self, layer: int, name: MaterialAttribute) -> int

ID of a named attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_id(self, name: str) -> int

ID of a named attribute in the base material

Exceptions
KeyError If name isn’t present in the base material

def magnum.trade.MaterialData.attribute_id(self, name: MaterialAttribute) -> int

ID of a named attribute in the base material

Exceptions
KeyError If name isn’t present in the base material

def magnum.trade.MaterialData.attribute_name(self, layer: str, id: int) -> str

Name of an attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute_name(self, layer: MaterialLayer, id: int) -> str

Name of an attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute_name(self, layer: int, id: int) -> str

Name of an attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute_name(self, id: int) -> str

Name of an attribute in the base material

Exceptions
IndexError If id is negative or not less than attribute_count()

def magnum.trade.MaterialData.attribute_type(self, layer: str, name: str) -> MaterialAttributeType

Type of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_type(self, layer: str, name: MaterialAttribute) -> MaterialAttributeType

Type of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_type(self, layer: str, id: int) -> MaterialAttributeType

Type of an attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute_type(self, layer: MaterialLayer, name: str) -> MaterialAttributeType

Type of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_type(self, layer: MaterialLayer, name: MaterialAttribute) -> MaterialAttributeType

Type of a named attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_type(self, layer: MaterialLayer, id: int) -> MaterialAttributeType

Type of an attribute in a named material layer

Exceptions
KeyError If layer doesn’t exist
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute_type(self, layer: int, name: str) -> MaterialAttributeType

Type of a named attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_type(self, layer: int, name: MaterialAttribute) -> MaterialAttributeType

Type of a named attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If name isn’t present in layer

def magnum.trade.MaterialData.attribute_type(self, layer: int, id: int) -> MaterialAttributeType

Type of an attribute in given material layer

Exceptions
IndexError If layer is negative or not less than layer_count
IndexError If id is negative or not less than attribute_count() for layer

def magnum.trade.MaterialData.attribute_type(self, name: str) -> MaterialAttributeType

Type of a named attribute in the base material

Exceptions
KeyError If name isn’t present in the base material

def magnum.trade.MaterialData.attribute_type(self, name: MaterialAttribute) -> MaterialAttributeType

Type of a named attribute in the base material

Exceptions
KeyError If name isn’t present in the base material

def magnum.trade.MaterialData.attribute_type(self, id: int) -> MaterialAttributeType

Type of an attribute in the base material

Exceptions
IndexError If id is negative or not less than attribute_count()

def magnum.trade.MaterialData.has_attribute(self, layer: str, name: str) -> bool

Whether a named material layer has given attribute

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.has_attribute(self, layer: str, name: MaterialAttribute) -> bool

Whether a named material layer has given attribute

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.has_attribute(self, layer: MaterialLayer, name: str) -> bool

Whether a named material layer has given attribute

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.has_attribute(self, layer: MaterialLayer, name: MaterialAttribute) -> bool

Whether a named material layer has given attribute

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.has_attribute(self, layer: int, name: str) -> bool

Whether a material layer has given attribute

Exceptions
IndexError If layer is negative or not less than layer_count

def magnum.trade.MaterialData.has_attribute(self, layer: int, name: MaterialAttribute) -> bool

Whether a material layer has given attribute

Exceptions
IndexError If layer is negative or not less than layer_count

def magnum.trade.MaterialData.layer_factor(self, layer: str) -> float

Factor of a named layer

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.layer_factor(self, layer: MaterialLayer) -> float

Factor of a named layer

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.layer_factor(self, layer: int) -> float

Factor of given layer

Exceptions
IndexError If layer is negative or not less than layer_count

def magnum.trade.MaterialData.layer_factor_texture(self, layer: str) -> int

Factor texture ID for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture(self, layer: MaterialLayer) -> int

Factor texture ID for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture(self, layer: int) -> int

Factor texture ID for given layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_coordinates(self, layer: str) -> int

Factor texture coordinate set for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_coordinates(self, layer: MaterialLayer) -> int

Factor texture coordinate set for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_coordinates(self, layer: int) -> int

Factor texture coordinate set for given layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_layer(self, layer: str) -> int

Factor array texture layer for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_layer(self, layer: MaterialLayer) -> int

Factor array texture layer for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_layer(self, layer: int) -> int

Factor array texture layer for given layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_matrix(self, layer: str) -> Matrix3

Factor texture coordinate transformation matrix for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_matrix(self, layer: MaterialLayer) -> Matrix3

Factor texture coordinate transformation matrix for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_matrix(self, layer: int) -> Matrix3

Factor texture coordinate transformation matrix for given layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_swizzle(self, layer: str) -> MaterialTextureSwizzle

Factor texture swizzle for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_swizzle(self, layer: MaterialLayer) -> MaterialTextureSwizzle

Factor texture swizzle for a named layer

Exceptions
KeyError If layer doesn’t exist
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_factor_texture_swizzle(self, layer: int) -> MaterialTextureSwizzle

Factor texture swizzle for given layer

Exceptions
IndexError If layer is negative or not less than layer_count
KeyError If MaterialAttribute.LAYER_FACTOR_TEXTURE isn’t present in layer

def magnum.trade.MaterialData.layer_id(self, layer: str) -> int

ID of a named layer

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.layer_id(self, layer: MaterialLayer) -> int

ID of a named layer

Exceptions
KeyError If layer doesn’t exist

def magnum.trade.MaterialData.layer_name(self, layer: int) -> str

Layer name

Exceptions
IndexError If layer is negative or not less than layer_count