modelx.write_model(model, model_path)[source]

Write model to files.

Write model to text files in a folder(directory) tree at model_path.

Model attributes, such as its name and refs, are output in the file named, directly under model_path. For each space in the model, a text file is created with the same name as the space with “.py” extension. The tree structure of the spaces is represented by the tree of folders, i.e. child spaces of a space is stored in a folder named the space.

Generated text files are Python pseudo-scripts, i.e. they are syntactically correct but semantically not-correct Python scripts, that can only be interpreted through read_model() function.

Dynamic spaces and cells values are not stored.

For spaces and cells created by new_space_from_excel() and new_cells_from_excel(), the source Excel files are copied into the same directory where the text files for the spaces the methods are associated with are located. Then when the model is read by read_model() function, the methods are invoked to create the spaces or cells.

Method write() performs the same operation.


This function and write() method do not work property in combination with new_cells_from_excel(), when new_cells_from_excel() creates more than one cells at a time.

  • model – Model object to write
  • model_path (str) – Folder path where the model will be output.