Skip to main content
1-Visitor
September 6, 2016
Question

Using Matrix with Prime 3.1 API

Hello,

does anyone of you have an example on how to deal with matrices with Prime 3.1 and the API. I want to create a matrix, fill it with data and then send the matrix to Prime.

The SDK does not contain any example for that.

Thanks in advance

Jan

4 replies

24-Ruby IV
September 7, 2016

Jan Christoph Wehrstedt написал(а):

Hello,

I want to create a matrix, fill it with data and then send the matrix to Prime.

Jan

The READPRN function in not ready for this task?

Translate
1-Visitor
September 7, 2016

Perhaps Andrew Carter‌ can help you.

 

He said:

I have succeeded in sending a matrix of numerical values with and without units, and also individual string values.  But can't seem to find how to send a matrix of strings.

In the following thread: Solved: Trying to populate string data array using API - PTC Community

Translate
1-Visitor
September 7, 2016

Here is some code that may help:

var appCreate = new Ptc.MathcadPrime.Automation.ApplicationCreatorClass();

Ptc.MathcadPrime.Automation.ApplicationCreator app;

app = (Ptc.MathcadPrime.Automation.ApplicationCreator)appCreate;

Ptc.MathcadPrime.Automation.IMathcadPrimeWorksheet3 ws;

ws = (Ptc.MathcadPrime.Automation.IMathcadPrimeWorksheet3) app.Open(WorksheetFileName);

int numRows = // whatever;

int numCols = // whatever;

                               

Ptc.MathcadPrime.Automation.IMathcadPrimeMatrix matrixValue = (Ptc.MathcadPrime.Automation.IMathcadPrimeMatrix) ws.CreateMatrix(numRows, numCols);

                               

for (int j = 1; j <= numRows; j++)

{

  for (int k = 1; k <= numCols; k++)

  {

  double valueArg = // In my case I fetch valueArg from some other system here

  matrixValue.SetMatrixElement(j - 1, i - 1, valueArg);

  }

}

string aliasArg = // whatever

string unitsArg = // whatever;

                             

ws.SetMatrixValue(aliasArg, matrixValue, unitsArg);

Translate
1-Visitor
September 9, 2016

perfect this really helps. I am a little surprised that this cannot be found in the SDK. Do you also have an example for the opposite direction (reading of a matrix)?

Have a nice weekend

Jan

Translate