Skip to main content
1-Visitor
December 6, 2021
Question

Access MathCAD Prime-data via Visual Basic (Script worked with MathCAD 15.0)

  • December 6, 2021
  • 2 replies
  • 3002 views

I am using Mathcad Prime 7.0 7.0.0.0

With an VisualBasic Programm we extract Calculations out of MathCAD 15.0
into an Excel Table.
I managed to transform the file from MathCAD 15.0 into MathCAD Prime 7.0
but the extraction of the values does not work.

I managed to open the

I changed
"GetValue" -> "InputGetValue"
and
"getelement" -> "GetMatrixElement"
but the values still do not get transfered to Excel.

What is the right syntax to adress the values in MathCAD Prime?
(mcws stands for MathCAD-Worksheet)

VB-Script-Line for MathCAD 15.0:

Set MC = CreateObject("Mathcad.Application")
Set mcws = MC.Worksheets.Open(pfad & Worksheets("Stammdaten").Range("MCDatei"))
...
WertEinlesenMCAD.uwrk = mcws.GetValue(varname).getelement(0, 0)



Script for MathCAD Prime 7.0:

Set MC = CreateObject("MathcadPrime.Application")
MC.Visible = True
MC.Activate
Set mcws = MC.Open(pfad & Worksheets("Stammdaten").Range("MCDatei"))
....
WertEinlesenMCAD.uwrk = mcws.InputGetValue(varname).GetMatrixElement(0, 0)

2 replies

24-Ruby III
December 6, 2021

Hi,

please ask PTC Support.

24-Ruby III
December 6, 2021
21-Topaz II
December 6, 2021

Hi,

In Prime  there is an additional step to pass variables to and from the API.

On the Prime window ribbon menu "Input/Output | Integration | Assign Inputs" where exchange variables are identified.

Refer to the help which is where the image came from.

Cheers Terry

 

Capture.JPG 

 

TJS1-VisitorAuthor
1-Visitor
December 10, 2021

I made the calculations to "Output", but still the transfer does not work.

 

 

TJS_0-1639147337453.png

Even when "varname" matches exactly the Alias of the Output, I won't get a value transfered.

WertEinlesenMCAD.uwrk = mcws.InputGetValue(varname).GetMatrixElement(0, 0)

21-Topaz II
December 10, 2021

Hi,

The terminology is a little difficult.

Use input for getvalue!

 

It is Input to API and output from the API?

 

As per the example supplied no dot in the alias.

Capture.JPG

Cheers

Terry