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

Mathcad Prime Interface / API

Participant

Mathcad Prime Interface / API

Hello,

 

I'm developing a custom application that communicates to Mathcad Prime. I would like to ask few questions related to Mathcad Prime Interface as below:

 

  1. Is there any database used by MC15 or MCP?
  2. What are the interfaces / APIs available to integrate with a custom solution?
  3. What language these APIs are developed? Are there any C# .Net interfaces available?
  4. What would be the cost of SDK? and is it a bulk license or one license per developer?

Kindly share your inputs.

 

Thanks & Regards,

Ashish

Tags (2)
4 REPLIES 4

Re: Mathcad Prime Interface / API

1. What do you mean by 'database used'? Almost every serious computer program uses a database of some sort. If not for functional reasons, then at least for administrative purposes, internally. You can think of the MuPad library of symbolic functions, bundled with Prime, as a database. Would you be able to access and/or manipulate that database via the API...? I think NOT.

2. There is an API available.

3. Since Prime is programmed in .Net, I would assume that you talk from .Net to the API.

4. The SDK, if you are referring to the suite of documentation of the API with examples of how to use it, is expensive. I seem to remember $5k. No, found it... it's $9k  per company. Read this:

https://community.ptc.com/t5/PTC-Mathcad/NEW-API-for-Mathcad-Prime-3-1/m-p/12388#M4769

 

Success!

Luc

Re: Mathcad Prime Interface / API

Hi,

 

Followed the discussions on your link.  Lots of complaints about the 9k.

Files are now:

Ptc.MathcadPrime.Automation.dll
Ptc.MathcadPrime.Automation.tlb

D:\Program Files\Mathcad Prime 5.0.0.0 

 

You can read the tlb file in Visual Studio Community 2015 like the discussion said to examine the objects, methods etc.

 

Cheers

Re: Mathcad Prime Interface / API

Hi,

 

  1. Is there any database used by MC15 or MCP?'

MCP has a "database" of input and output regions declared in a worksheet.  Each input output has an "alias" in the database used to communicate data.  You can manually change the names of aliases.

Capture2.JPG

 

2. What are the interfaces / APIs available to integrate with a custom solution?

 

Two file are included in the Prime distribution

Ptc.MathcadPrime.Automation.dll

Ptc.MathcadPrime.Automation.tlb.

Using Visual Studio 2017 Community you "add a reference" to a project.  Select Project | Add a Reference.  select the COM section from the left hand menu.  Use the Browse button go to the Mathcad Prime distribution and select the dll file.  This will add the dll and tlb to the project and more importantly gives you intellisense on using the classes in the IDE and the classes are available in the object browser.

 

3. What language these APIs are developed? Are there any C# .Net interfaces available?

 

You can use in Visual Studio 2017 Community either Visual Basic or C# to program.  Enclosed here is the visual C# that inputs and outputs to Mathcad both doubles and matrices of doubles

Capture.JPG

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Ptc.MathcadPrime.Automation;

namespace mathcad3
{
public partial class Form1 : Form
{

 

public Form1()
{
InitializeComponent();
}

 

/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click_1(object sender, EventArgs e)
{
var appCreate = new ApplicationCreatorClass();
ApplicationCreator app;
app = (ApplicationCreator)appCreate;
IMathcadPrimeWorksheet3 ws;
ws = (IMathcadPrimeWorksheet3)app.Open(@"D:\\Prime\\VB\\Test.mcdx");

app.Visible = true;
double output;

IMathcadPrimeWorksheet wsTest = app.ActiveWorksheet;
ws = (IMathcadPrimeWorksheet3)wsTest;

wsTest.SetRealValue("B", 22.5, "");

IMathcadPrimeOutputResult resolve = wsTest.OutputGetRealValue("out");
output = resolve.RealResult;
textBox1.Text = output.ToString();

int i = 5;
IMathcadPrimeMatrix matrixValue = (IMathcadPrimeMatrix)ws.CreateMatrix(3, 3);

i = matrixValue.SetMatrixElement(0, 0, 2.5);
i = matrixValue.SetMatrixElement(0, 1, 4.0);
i = matrixValue.SetMatrixElement(0, 2, 3.1);
i = matrixValue.SetMatrixElement(1, 0, 1.5);
i = matrixValue.SetMatrixElement(1, 1, 3.6);
i = matrixValue.SetMatrixElement(1, 2, 5.0);
i = matrixValue.SetMatrixElement(2, 0, 7.2);
i = matrixValue.SetMatrixElement(2, 1, 4.8);
i = matrixValue.SetMatrixElement(2, 2, 6.8);

ws.SetMatrixValue("M", matrixValue, "");

IMathcadPrimeOutputMatrixResultAs hereResult = ws.OutputGetMatrixValueAs("here", "");
double wshereResultRowsCount = hereResult.MatrixResult.Rows;
double wshereResultColsCount = hereResult.MatrixResult.Columns;

double dblhere;

for (int ic = 0; ic < wshereResultRowsCount; ic++)
{

for (int jc = 0; jc < wshereResultColsCount; jc++)
{
hereResult.MatrixResult.GetMatrixElement(ic, jc, out dblhere);
richTextBox1.AppendText(Convert.ToString(dblhere));
richTextBox1.AppendText(", ");

}
richTextBox1.AppendText("\n");

}

 

((IMathcadPrimeWorksheet3)ws).Close(SaveOption.spPromptToSaveChanges);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ws);
app.CloseAll(SaveOption.spDiscardChanges);
app.Quit(SaveOption.spDiscardChanges);
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
System.Runtime.InteropServices.Marshal.ReleaseComObject(appCreate);
}
}
4. What would be the cost of SDK? and is it a bulk license or one license per developer?

Why spend the $9k for the examples.   The intellisense feature of Visual Studio and the object browser gives you all the classes etc.  Above is a simple example that works.  There are a number of other examples available in this forum and on the www.

 

Cheers

Terry

 

Highlighted

Re: Mathcad Prime Interface / API

The API is built in to Prime. The SDK, you have to pay for (a ridiculous amount of money too). As far as I know, it works in the trial version. What are you trying to do?