Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
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
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
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