Model.path#

property Model.path#

A Path object representing the model’s path.

When a previously saved model is loaded with read_model(), this property is set to a pathlib.Path object representing the path given to read_model():

>>> import modelx as mx
>>> model = mx.read_model(r"C:\Users\mxuser\Model")
>>> model.path
WindowsPath('C:/Users/mxuser/Model2')

When a model is created with new_model(), this property is set to None:

>>> model = mx.new_model()
>>> model.path     # Returns None

The user can set the path by assigning a string value to it:

>>> model.path = "."
>>> model.path
WindowsPath('.')

When a model is saved with write() or write_model(), this property is updated to a pathlib.Path object representing the path given to the method or function:

>>> model.write(r"C:\Users\mxuser\Model2")
>>> model.path
WindowsPath('C:/Users/mxuser/Model2')

The property is accessed within formulas as an attribute of a special Reference, model_:

>>> @mx.defcells
>>> def foo():
...     return _model.path
>>> foo()
WindowsPath('C:/Users/mxuser/Model')
Returns:

A pathlib.Path object or None

New in version 0.25.0.