MAXON API - Functions

Methods Signature

maxon.finally_once(func, *args, **kwargs) Executes a function when the current scope is left.
maxon.MAXON_SOURCE_LOCATION([offset]) Creates a SourceLocation object for the current Python Frame.
maxon.MAXON_ATTRIBUTE(id) Alias for a maxon.InternedId.
maxon.GetDataType(obj) Retrieves the maxon.DataType of the passed object.
maxon.MaxonConvert(*args) Convert all passed objects to a maxon or Python object, depending on the passed type.
maxon.ToBlock(data, size[, stride, dt]) Makes a maxon.Block or a maxon.StridedBlock from a pointer, a size and a stride.
maxon.InternedIdToString(addr) Converts a maxon.InternedId to a Python string
maxon.Cast(T, o) Cast the object o to the type T.
maxon.reinterpret_cast(T, o) Cast(T, o) Cast the object o to the type T.

Methods Definition

maxon.finally_once(func, *args, **kwargs)

Executes a function when the current scope is left.

Note

An optional parameter canRaise can be passed to notify that func may eventually raise.

Parameters:
  • func (function(*args, **kwargs)) – Function to be called.
  • args (Any) – Optional arguments to be passed to func.
  • kwargs (Any) – Optional settings like canRaise to control if func can raise an exception.
cleanup = finally_once(lambda x: MyFunction(x), canRaise=False)
maxon.MAXON_SOURCE_LOCATION(offset=0)

Creates a SourceLocation object for the current Python Frame.

Parameters:offset (Optional[int])) – Optional trace back offset to retrieve the current source location from.
Returns:The source location corresponding to the Python frame calling this function.
Return type:maxon.SourceLocation
maxon.MAXON_ATTRIBUTE(id)

Alias for a maxon.InternedId. :param id: The string representation of the maxon.InternedId you want to declare. :type id: str :return: The maxon.InternedId. :rtype: maxon.InternedId

maxon.GetDataType(obj)

Retrieves the maxon.DataType of the passed object.

Parameters:type – The object to retrieves the maxon.DataType from.
Type:Any maxon API class
Returns:The datatype.
Return type:maxon.DataType
maxon.MaxonConvert(*args)

Convert all passed objects to a maxon or Python object, depending on the passed type.

Note

Latest arguments determine how the conversion is done by passing a maxon.CONVERSIONMODE.

import maxon

# Returns a maxon.Int32 of value 10
print maxon.MaxonConvert(10)

# Returns a int of value 10
print maxon.MaxonConvert(maxon.Int(10))

# Forces a return value to Maxon API type, in this case a maxon.Int32 of value 10
print maxon.MaxonConvert(maxon.Int(10), maxon.CONVERSIONMODE.TOMAXON)

# Forces a return value to Python Builtin, in this case a int of value 10
print maxon.MaxonConvert(10, maxon.CONVERSIONMODE.TOBUILTIN)
Parameters:args (Any) – The object to converts.
Returns:The object converted
Return type:Any
maxon.ToBlock(data, size, stride=None, dt=None)

Makes a maxon.Block or a maxon.StridedBlock from a pointer, a size and a stride.

Parameters:
  • data (Any.) – The data to transform to a Block.
  • size (int) – Number of elements.
  • stride (int) – Element stride.
  • dt (maxon.DataType) – The Datatype of the data to be converted as block
Returns:

A block of elements for this data and datatype.

Return type:

Union[maxon.StridedBlock, maxon.Block]

maxon.InternedIdToString(addr)

Converts a maxon.InternedId to a Python string

Parameters:addr (maxon.InternedId) – The maxon.InternedId to convert.
Returns:The string representation.
Return type:str
maxon.Cast(T, o)

Cast the object o to the type T.

Warning

This function is only there to expose a C++ Object to Python.
As a Python developer you normally don’t have to deal with this function.
Parameters:
  • T (type) – The type to cast the object to.
  • o (Any) – The Initial object
Returns:

The casted object

Return type:

T

maxon.reinterpret_cast(T, o)

Cast(T, o) Cast the object o to the type T.

Warning

This function is only there to expose a C++ Object to Python.
As a Python developer you normally don’t have to deal with this function.
Parameters:
  • T (type) – The type to cast the object to.
  • o (Any) – The Initial object
Returns:

The casted object

Return type:

T