2.1.18 GetMatrix


Description

The GetMatrix method transfers data from specified Origin matrix.

Syntax

VB: Function GetMatrix(Name As ByVal String, [ format As ByVal Object ] ) As Object
C++: _variant_t GetMatrix(LPCSTR Name, _variant_t format )
C#: var GetMatrix(string Name, var format )

Parameters

Name
The range string of the Origin worksheet to be found. The range string contains the book name between square brackets followed by the sheet name:
[<bookName>]<sheetName>!<objIndex>
The following special notations are supported. When any of the three parts are not specified then the active is used:
  1. "" (empty string) -- get the active object from the active sheet from the active book
  2. "[MBook1]" or "MBook1" -- get the active object from the active sheet from the named book
  3. "[MBook1]MSheet1" or "[MBook1]MSheet1!" -- get the active object from the named sheet from the named book
  4. "MSheet!" -- get the active object from the named sheet from the active book
  5. "MSheet!0" -- get the specified object from the named sheet from the active book
format
This is optional argument reserved for future use. Defaults to 0.

Return

Returns data as two dimensional safearray of doubles.

Remark

Examples

VBA

'Assumes Matrix1 exists and contains data.
Dim oApp As Origin.ApplicationSI
Set oApp = GetObject("", "Origin.ApplicationSI")
array = oApp.GetMatrix("Matrix1")

C#

        public void GetMatrix()
        {
            Origin.IOApplication pOrigin;
            object mtx;

            pOrigin = new Origin.ApplicationSIClass();
            mtx = pOrigin.GetMatrix("MBook1", 0); //matrix with book name of MBook1
            int dd = -1; //if fail to get matrix, it mtx will be minus value
            if ( mtx == null || mtx.GetType() == dd.GetType() )
            {
                return; //can not get matrix
            }
            double[,] data = mtx as double[,];
            System.Console.WriteLine(data[1, 1]); //first cell of the first column
        }
        static void Main(string[] args)
        {
            Program p = new Program();
            p.GetMatrix();
        }

Python

import OriginExt as O
app = O.Application(); app.Visible = app.MAINWND_SHOW
pageName = app.CreatePage(app.OPT_MATRIX)
mp = app.MatrixPages(pageName)
ms = mp.Layers(0)
# Set number of matrix objects
ms.Mats = 1
# Set the dimension of matrix
ms.Rows = 3; ms.Cols = 2
# Set the data of matrix object
testData = [[5,87,90], [3.14, 24.6, 68.09]]
app.PutMatrix(pageName, testData)
outputData = app.GetMatrix(pageName)

Version Information

8.0SR2

See Also

PutMatrix