Skip to main content
13-Aquamarine
March 17, 2015
Question

NEW API for Mathcad Prime 3.1

  • March 17, 2015
  • 4 replies
  • 28529 views

Can someone point me to the user guide to use the NEW API in Mathcad prime 3.1

The help system mentions that the user guide is available but does not give a link to it, does not give an online help to it. Also, it seems to implt that you have to pay for teh API!!!!

If so this is ridiculous. 3.1 is advertised as having an API as part of its features!!!

Can someone shed some light on this?

Thanks

4 replies

1-Visitor
March 17, 2015


Steve,

The API is part of Mathcad Prime 3.1 install. Look for MathcadPrimeAutomation.tlb and MathcadPrimeAutomation.dll.

Load the TLB into the Object Browser of MS Visual Studio (or Visual Studio Express ..free) and there are the API's, their

methods, properties, enums and data types.

What's for sale is the Mathcad Prime 3.1 SDK which is a package of documentation and source code examples

including source to the Solidworks- Mathcad Prime integration.

So to be clear .. API is free, SDK is for sale. BTW SDK is $9000 USD per company.

John

19-Tanzanite
March 17, 2015

Seriously? You are asking $9000 for the documentation for the API? That is what I would call a gross rip-off! In fact, I think it's the biggest rip-off I have ever heard of. You are basically asking $9k for a book!

1-Visitor
March 17, 2015

No, not $9000 per company for documentation.

$9000 per company for the entire SDK, which is mostly source code

examples.

Once more, open the TLB in Visual Studio. There is everything. If you like, print to PDF.


1-Visitor
October 12, 2015

This is how to get started with C#

Add a reference to the Ptc.MathcadPrime.Automation.dll

add a using statement

public partial class MainWindow : Window

{

   ApplicationCreator app;

   public MainWindow()

  {

   var appCreate = new ApplicationCreatorClass();

  app = (ApplicationCreator)appCreate;

   }



   private void Button_Click(object sender, RoutedEventArgs e)

  {

   var ws = app.Open("PATH TO YOUR FILE");

   var inputs = ws.Inputs;

   ----------------------------- 

      Work with your file

     ---------------------------------

 

  app.Quit(SaveOption.spSaveChanges);

     }

}

I hope this is to some help.

1-Visitor
October 13, 2015

Interesting coincidence that I happened to be working on connecting to Mathcad Prime with VBA today.  After some playing around I have some working code.

First some notes:

- I am currently only interested in obtaining results from Mathcad (looking at outputs only, not inputs).  However, I assume similar code can be used to set values.

- In the Mathcad document, you must assign your inputs/outputs under the "Input/Output" tab, in the "Integration" section.  Using the "Show as List" button, you can see the assigned Inputs/Outputs and view and/or modify their "Alias".

- The following code will run through all the assigned Outputs and list their alias, real value, and unit (in the "Immediate" window):

Sub MathcadPrimeGetValues()

  Dim MC As Ptc_MathcadPrime_Automation.Application

  Dim WS As Ptc_MathcadPrime_Automation.Worksheet

  Dim MCOuts As Ptc_MathcadPrime_Automation.Outputs

  Dim MCAlias As String

  Dim MCResult As Ptc_MathcadPrime_Automation.GetValueResult

  Dim FilePath As String

  Dim i As Long

 

  FilePath = "Mathcad File Path"

 

  Set MC = New Ptc_MathcadPrime_Automation.Application

  Set WS = MC.Open(FilePath)

  Set MCOuts = WS.Outputs

  For i = 0 To MCOuts.Count - 1

    MCAlias = MCOuts.GetAliasByIndex(i)

    Set MCResult = WS.OutputGetValue(MCAlias)

    Debug.Print MCAlias; MCResult.RealResult; MCResult.Units

  Next i

 

  WS.Close (SaveOption_spDiscardChanges)

  MC.Quit (SaveOption_spDiscardChanges)

  Set MCResult = Nothing

  Set MCOuts = Nothing

  Set WS = Nothing

  Set MC = Nothing

End Sub

1-Visitor
October 13, 2015

In the following (and attached) Mathcad file, you can see that I've defined two variables and assigned their results as outputs.  By default, Mathcad gives the outputs the aliases "out", "out_0", and so on.  These can be changed manually to something more useful (if anyone knows how to do this programmatically, that would save me a lot of work - please share).  When I run the script above, I get the following:

out    0.0762    m

out_0    0.127    m

tslewis13-AquamarineAuthor
13-Aquamarine
December 21, 2016

So, I have made some headway but it is not possible to access the contents of an output value result that is a matrix composed only of strung values. It only works for numbers, great. Amy idea when this bug will be fixed?

19-Tanzanite
December 21, 2016

Amy idea when this bug will be fixed?

There are no bugs in Prime. Just missing features. A lot of missing features, but no bugs

tslewis13-AquamarineAuthor
13-Aquamarine
December 21, 2016

β€Œand they want to change 9k for an sdk that doesn't even fully expose all of the objects in output values? What's the use of a matrix if you can only work with numbers?

24-Ruby III
January 11, 2019

The "Mathcad Prime API SDK" package includes:

 * PDF file "Mathcad Prime SDK Guide";

 * PDF file "SolidWorks-Mathcad Prime Integration User Guide";

 * A set of programs examples with the description for the following programming languages:

      C# 
      C#.NET
      C++.NET

      VB.NET

      vbscript

      javascript
      html-javascript

 * Example for SolidWorks-Mathcad Prime integration.