Reads and writes Rhino worksession (.rws) files. A worksession file lists models and a worksession's layer overrides. It does not contain any model content, and nothing here opens or checks the model files it lists.
Remarks: Rhino 4 wrote version 4 files. Rhino 5 and later write version 5. Both versions can be read and written. Models are exchanged by value: GetModel(int) returns a copy, and changes to it are kept only after SetModel(int, WorksessionFileModel).
Constructors
public WorksessionFile(WorksessionFile other)
Creates a copy of another worksession.
Parameters:
| other (WorksessionFile) | The worksession to copy. |
Exceptions:
| ArgumentNullException | If other is null. |
Finalizer
Properties
Gets the index of the first active model, or -1 if there is no active model.
The worksession file version Rhino 5 and later write.
Gets or sets the file version. Reading sets it to the version of the file that was read. Writing does not use it.
Exceptions:
| ArgumentOutOfRangeException | If the value is negative. |
Methods
Adds a copy of a model to the end of the list.
Parameters:
| model (WorksessionFileModel) | The model to copy. |
Exceptions:
| ArgumentNullException | If model is null. |
Describes the worksession: its version, and for each model its paths and saved layer settings. For each saved layer it gives its name and the settings Rhino uses.
Reads a worksession from the contents of a worksession file.
Parameters:
| bytes (byte[]) | The contents of a .rws file. |
Returns: The worksession, or null if the bytes could not be read, including the contents of a worksession file from a newer version of Rhino.
Exceptions:
| ArgumentNullException | If bytes is null. |
Gets a copy of a model.
Parameters:
| index (int) | Index of the model. |
Returns: A copy of the model. Changes to it are kept only after SetModel(int, WorksessionFileModel).
Exceptions:
| ArgumentOutOfRangeException | If index is out of range. |
Reads a worksession file.
Parameters:
| path (string) | The file to read. |
Returns: The worksession, or null if the file could not be read. That includes a worksession file from a newer version of Rhino: ReadFileVersion(string) returns a version greater than CurrentVersion for those, and 0 for a file that is not a worksession file.
Exceptions:
| ArgumentNullException | If path is null. |
Reads only the version from the header of a worksession file.
Parameters:
| path (string) | The file to read. |
Returns: The file's version, or 0 if the file cannot be read or is not a worksession file. A version greater than CurrentVersion is from a newer version of Rhino.
Exceptions:
| ArgumentNullException | If path is null. |
Removes a model.
Parameters:
| index (int) | Index of the model to remove. |
Exceptions:
| ArgumentOutOfRangeException | If index is out of range. |
Replaces a model with a copy of another.
Parameters:
| index (int) | Index of the model to replace. |
| model (WorksessionFileModel) | The model to copy. |
Exceptions:
| ArgumentNullException | If model is null. |
| ArgumentOutOfRangeException | If index is out of range. |
Writes the worksession as the contents of a version 5 .rws file.
Returns: The file contents, or null if the worksession could not be written.
Writes the worksession as the contents of a .rws file.
Parameters:
| version (int) | 4 or 5. |
Returns: The file contents, or null if the worksession could not be written.
Writes a worksession file.
Parameters:
| path (string) | The file to write. |
| version (int) | 4 or 5. Version 4 needs exactly one active model and saves only the model file paths. |
Returns: True if the file was written. If false is returned, an existing file is left as it was.
Exceptions:
| ArgumentNullException | If path is null. |
Writes a version 5 worksession file.
Remarks: The first active model is written first and the other models follow in order. Models with an empty full path are not written. Paths are written as they are, and are not checked or changed.
Parameters:
| path (string) | The file to write. |
Returns: True if the file was written. If false is returned, an existing file is left as it was.
Exceptions:
| ArgumentNullException | If path is null. |