Skip to main content
1-Visitor
September 8, 2013
Solved

Mathcad API and functions y(x)

  • September 8, 2013
  • 1 reply
  • 2343 views

Hello,

I´m having troubles using the MathCAD API to evaluate functions in a worksheet. Maybe someone here can help me?

I´d like to geht the following to work:

In my MathCAD Worksheet I got: y(x):= 2x

And now I´d like to access this function using the API

MCAppl = new Mathcad.Application();

MCWs = MCAppl.ActiveWorksheet;

And now evaluate the function, for example

y = MCWs.GetValue("y(3)").Real;

But this command is not working for me. I tried different ways of typing it, but no success.

It works the following way:

Define variable x and put y:=2x in MathCAD

MCWs.SetValue("x", 3);

y = MCWs.GetValue("y").Real;

But I already got a big document using functions, rewriting the whole document is not an option. So is there any way to evaluate functions using the API? Or is this a bug in Mathcad or its API?

I´d prefer using python for the API, but C# is also an option. Doesn´t seem to much difference between the two when accessing Mathcad. Right now I´m on Mathcad 14.0M20, a short testing on Mathcad 15 did not change anything.

Any clues?

Thanks already for any hints!

Tilman

Best answer by RichardJ

You can't access functons via the API, only variables.

1 reply

RichardJ19-TanzaniteAnswer
19-Tanzanite
September 9, 2013

You can't access functons via the API, only variables.

Tilman1-VisitorAuthor
1-Visitor
September 9, 2013

Thank you, at least it was not my fault. Using a workaround already!