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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

NEW API for Mathcad Prime 3.1

tslewis
11-Garnet

NEW API for Mathcad Prime 3.1

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

44 REPLIES 44

Thanks for the detailed explanation, Richard.

StuartBruff
23-Emerald II
(To:RichardJ)

Richard Jackson wrote:

...You can also develop GUI based standalone applications, but not as easily as with Visual Studio / C#. So Python is great for numerical computing, not so great for building GUI based apps.

How about if you throw the Visual Studion Python extensions into the picture?

Python Tools for Visual Studio

Stuart

RichardJ
19-Tanzanite
(To:StuartBruff)

I wasn't even aware that existed. Nice

I still have no had a response to this.

I have not had any success implementing the API. I am an experienced programmer.

I CANNOT BELIEVE YOU ADVERTISE AN API BUT PROVIDE ZERO DOCUMENTATION AND NO OPTION FOR IT UNLESS YOU PAY 9000 DOLLARS UNBELIEVABLE.

SEE THIS LINK TO A BLOG FOR CONFIRMATION. I HAVE SPENT SEVERAL HOURS GETTING TI TO WORK. I AM UNABLE TO GET A RUNNING INSTANCE OF THE APPLICATION CLASS.. TERRIBLE. I GET ERROR MESSAGE EVRYTIME AND ONLY INTERFACES ARE EXPOSED AND WORKING. NO CLASSES CAN BE INSTANTIATED.

PTC Mathcad Prime 3.1 API + SDK | Product Lifecycle Report

PTC Mathcad Prime’s API is supported by a Software Development kit. The development kit is a collection of 10 applications which demonstrate the API abilities and provide the source code for the applications. They are written in C++.NET, C#.NET VB.NET, vbscript and javascript. These applications have custom GUIs to drive variables, write equations, leverage Google Graphs and integrate with Solidworks. And all the source code comes bundled plus a User’s Guide for the API.

The SDK is sold and licensed per company. Purchase of the SDK and its associated Global Support gets the SDK *and* access to Technical Support for help writing applications interacting with the API.

Thanks John for your answer, but sadly I need to say that you're wrong.

The API isn't self-explanatory, and isn't self-documented, at least in the way that you talk.

SAP2000, an important software for Structural Engineering Analisys and Design, have a well documented API, with a CHM file inside the installation directory. The API feature was included in SAP2000 since the V11 (year 2007) to the actual days (year 2015). In all that release, CSI attach to their published DLL, TLB or EXE a extensive CHM, with some examples, return values, strategy for developers, and typical use of all the API functions (download CHM).

CSI have a paid service that include "premium support for developers", this service is known as "CSIDN": CSI Developer Network | Computers and Structures, Inc. | Structural Engineering | Structural Analysis and Design Softwar…

CSIDN have a cost of USD2,000 the first year, then USD1,000 for the following years.

In the arena of the Math software, the direct competitor of PTC -Maplesoft- include a full documentation inside the help of their Maple application. That help is fantastic, have examples for many many languages, return values, functions usage...

2015-05-09_13-58-43.png

Matlab have a deep documentation too, aven accessible from the website of Matlab.

John, in this PTC video your company show "how to work with the new API": http://support.ptc.com/WCMS/files/165871/en/API_SDK.mp4

Really you think that with only the Object Browser inside Visual Studio IDE are enough for the engineers that perform developing task?. You try to make business with something that It must necessarily come bundled. And "forum" for experts developers of PTC...or a examples for "in time" import on Visual Studio...with samples, videos...audios...interactive "instructions manual" are the field for make money...but a minimal documentation with function usage, return values, some examples for implementing in different languages...that is an obligation for the company that sell the main software.

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.

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

MJG
18-Opal
18-Opal
(To:MJG)

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

sthomet
1-Newbie
(To:MJG)

Great work, Thank you!

rtam
2-Guest
(To:MJG)

to: MJGLevel 12 (in response to djohansson-2)... Could you help me out with the whole program in order to call an input and retrieve a computed output. I followed what you wrote but showed me errors on the .net compilation (raphaeltamariz@gmail.com)

tslewis
11-Garnet
(To:tslewis)

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?

RichardJ
19-Tanzanite
(To:tslewis)

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

‌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?

MJG
18-Opal
18-Opal
(To:tslewis)

FYI - there is discussion on this thread regarding matrices of strings.  No clear solution, but some suggestions.

Trying to populate string data array using API

VladimirN
24-Ruby II
(To:tslewis)

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.

Top Tags