cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Using Matrix with Prime 3.1 API

jwehrstedt
1-Visitor

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 4

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?

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

acarter-2
1-Visitor
(To:MJG)

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);

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

Announcements

Top Tags