1.20.2 Collections


The Collection class provides a template for holding multiple objects of the same type. In Origin C, an instance of a Collection is read-only. You cannot add items to, or delete items from, a collection.

There are a number of Origin C classes that contain data members which are instances of a Collection. For example, the Project class contains a data member named WorksheetPages. The WorksheetPages data member is a collection of all the existing WorksheetPage objects in the project.

The table below lists each of the Origin C Collections, along with the class that contains the collection and the item types in the collection.

Class Data Member Collection of
Folder Pages PageBase
Folder SubFolders Folder
GraphLayer DataPlots DataPlot
GraphLayer StyleHolders StyleHolder
GraphPage Layers GraphLayer
Layer GraphObjects GraphObject
MatrixLayer MatrixObjects MatrixObject
Page Layers Layer
Project DatasetNames string (loose and displayed datasets)
Project GraphPages GraphPage
Project LayoutPages LayoutPage
Project LooseDatasetNames string (loose datasets)
Project MatrixPages MatrixPage
Project Notes Note
Project Pages PageBase
Project WorksheetPages WorksheetPage
Selection Objects OriginObject
TreeNode Children TreeNode
Worksheet Columns Column
Worksheet EmbeddedPages Page

Examples

List all graph pages in the current project.

foreach(GraphPage gp in Project.GraphPages)
{
	out_str(gp.GetName());
}

List all worksheet pages in the current project.

foreach(WorksheetPage wksPage in Project.WorksheetPages)
{
	out_str(wksPage.GetName());
}

List all matrix pages in the current project.

foreach(MatrixPage matPage in Project.MatrixPages)
{
	out_str(matPage.GetName());
}

List all data plots.

GraphLayer gl = Project.ActiveLayer();
foreach(DataPlot dp in gl.DataPlots)
{
	string strRange;
	dp.GetRangeString(strRange, NTYPE_BOOKSHEET_XY_RANGE);
	
	printf("%d, %s", dp.GetIndex()+1, strRange);
}