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
I remember there were a few threads in this forum about exchanging matrices via the API in the past but I am not sure if there ever was a satisfying solution. You may try the search function in the forum to find those threads.
While not specifically covering python, maybe this post can be of help: https://community.ptc.com/t5/PTC-Mathcad/Using-Matrix-with-Prime-3-1-API/m-p/313195/highlight/true#M122230
I really appreciate it. I will look at it.
Is there anybody who can reach https://www.ptc.com/en/support/article/CS301830?
The name of article is 'Article - CS301830 How to set a matrix element value using API SetMatrixElement() and SetMatrixValue() in Mathcad Prime'.
It is the right thing for me.
Please help me look at the article.
JW
Here you are, but the "article" just consists of the code example which you can also find in the thread I linked to in my first answer.
------------------------------------------------------- snip -------------------------------------------------
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);
It is ridiculous. Even though I coded like the c++ in the above, it still does not work. I do not know where I start from.
--------------------
<Functions>