Rhino C++ API  9.0
Public Member Functions | Static Public Member Functions | List of all members
ON_WorksessionFile Class Reference

#include <opennurbs_worksession.h>

Public Member Functions

 ON_WorksessionFile ()
 
 ON_WorksessionFile (const ON_WorksessionFile &src)
 
 ~ON_WorksessionFile ()
 
int ActiveModelIndex () const
 Index of the first active model, or -1 if there is none. More...
 
void AppendModel (const ON_WorksessionModel &model)
 
void Dump (class ON_TextLog &text_log) const
 
const ON_WorksessionModel * Model (int index) const
 
int ModelCount () const
 
ON_WorksessionFile & operator= (const ON_WorksessionFile &src)
 
bool Read (const wchar_t *file_path)
 
bool Read (ON_BinaryArchive &archive)
 
void RemoveAllModels ()
 
bool RemoveModel (int index)
 Returns false if index is out of range. More...
 
bool SetModel (int index, const ON_WorksessionModel &model)
 Returns false if index is out of range. More...
 
void SetVersion (unsigned int version)
 
unsigned int Version () const
 Version of the file set by Read(), or 0. Write() does not use it. More...
 
bool Write (const wchar_t *file_path, unsigned int version=ON_WorksessionFile::CurrentVersion()) const
 
bool Write (ON_BinaryArchive &archive, unsigned int version=ON_WorksessionFile::CurrentVersion()) const
 

Static Public Member Functions

static unsigned int CurrentVersion ()
 The version Rhino 5 and later write. More...
 
static unsigned int FileVersion (const wchar_t *file_path)
 

Detailed Description

Description: 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. Remarks: Rhino 4 wrote version 4 files. Rhino 5 and later write version 5. Both versions can be read and written.

Constructor & Destructor Documentation

◆ ON_WorksessionFile() [1/2]

ON_WorksessionFile::ON_WorksessionFile ( )

◆ ~ON_WorksessionFile()

ON_WorksessionFile::~ON_WorksessionFile ( )

◆ ON_WorksessionFile() [2/2]

ON_WorksessionFile::ON_WorksessionFile ( const ON_WorksessionFile &  src)

Member Function Documentation

◆ ActiveModelIndex()

int ON_WorksessionFile::ActiveModelIndex ( ) const

Index of the first active model, or -1 if there is none.

◆ AppendModel()

void ON_WorksessionFile::AppendModel ( const ON_WorksessionModel &  model)

◆ CurrentVersion()

static unsigned int ON_WorksessionFile::CurrentVersion ( )
static

The version Rhino 5 and later write.

◆ Dump()

void ON_WorksessionFile::Dump ( class ON_TextLog &  text_log) const

Description: Prints the file's contents. For each saved layer it prints its name and the settings Rhino uses: visibility, locking, color, print color and width, model visibility, visibility in new details, whether it is expanded, and a CRC of the per-viewport settings.

◆ FileVersion()

static unsigned int ON_WorksessionFile::FileVersion ( const wchar_t *  file_path)
static

Returns: The version of the worksession file, or 0 if the file cannot be read or is not a worksession file.

◆ Model()

const ON_WorksessionModel* ON_WorksessionFile::Model ( int  index) const

Returns nullptr if index is out of range. The pointer is valid only until the list of models next changes.

◆ ModelCount()

int ON_WorksessionFile::ModelCount ( ) const

◆ operator=()

ON_WorksessionFile& ON_WorksessionFile::operator= ( const ON_WorksessionFile &  src)

◆ Read() [1/2]

bool ON_WorksessionFile::Read ( const wchar_t *  file_path)

Description: Reads a worksession file. Returns: True if the file was read. If false is returned, there are no models. Version() is set to the file's version whenever the file is a worksession file, including one from a newer version of Rhino that this code cannot read.

◆ Read() [2/2]

bool ON_WorksessionFile::Read ( ON_BinaryArchive &  archive)

Description: Reads a worksession from the current position in archive. Parameters: archive - [in] An archive in read mode, such as an ON_BinaryFile. A worksession file is not a .3dm archive and the chunks in it have 4 byte lengths. The archive's 3dm version is set to 0 while reading and restored afterwards.

◆ RemoveAllModels()

void ON_WorksessionFile::RemoveAllModels ( )

◆ RemoveModel()

bool ON_WorksessionFile::RemoveModel ( int  index)

Returns false if index is out of range.

◆ SetModel()

bool ON_WorksessionFile::SetModel ( int  index,
const ON_WorksessionModel &  model 
)

Returns false if index is out of range.

◆ SetVersion()

void ON_WorksessionFile::SetVersion ( unsigned int  version)

◆ Version()

unsigned int ON_WorksessionFile::Version ( ) const

Version of the file set by Read(), or 0. Write() does not use it.

◆ Write() [1/2]

bool ON_WorksessionFile::Write ( const wchar_t *  file_path,
unsigned int  version = ON_WorksessionFile::CurrentVersion() 
) const

Description: Writes a worksession file. Parameters: file_path - [in] version - [in] 4 or 5. Version 4 needs exactly one active model and saves only the model file paths. Returns: True if the file was written. Nothing is written, and an existing file is left as it was, if the worksession cannot be written in this version. 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.

◆ Write() [2/2]

bool ON_WorksessionFile::Write ( ON_BinaryArchive &  archive,
unsigned int  version = ON_WorksessionFile::CurrentVersion() 
) const

Description: Writes a worksession at the current position in archive. Parameters: archive - [in] An archive in write mode, such as an ON_BinaryFile. The archive's 3dm version is set to 0 while writing and restored afterwards. version - [in] 4 or 5.