4
$\begingroup$

I'm wondering if its possible push output from a .NET console application to an existing Notebook that is open in Mathematica.

The reason I'd like this is that I want to use Mathematica as a "debugging console" for intermediate calculations that I am performing in .NET, by pushing out text, graphics, etc.

p.s. I'm fairly familiar with C# and Mathematica, so all I want to know is if this is possible, or not.

$\endgroup$
  • 1
    $\begingroup$ It is possible via JLink (see the JLink docs for details, my quick search resulted in this link, but the updated version of this is now incorporated into the current JLink tutorial). I would guess .NET link should make this possible too. $\endgroup$ – Leonid Shifrin Aug 29 '12 at 8:41
3
$\begingroup$

See http://reference.wolfram.com/mathematica/tutorial/ManipulatingNotebooksFromTheKernel.html

If we send the following four commands to the Mathematica Kernel, via Net/Link, it will create a new notebook, and graph the result of an equation:

n = CreateWindow[]
NotebookWrite[n, "Plot[Sin[x],{x,0,6 Pi}]"]
SelectionMove[n, All, CellContents]
SelectionEvaluateCreateCell[n]

Here is the output in Mathematica. I think this is pretty cool: now I can use Mathematica as a kind of super charged debugging console from a .NET application, one which can plot graphic as well as print text. Any output graphs can then be interacted with, i.e. rotated, animated, etc.

enter image description here

Update

Unfortunately, this didn't end up working at all.

The following command does not work from .NET/Link, as its a function call contained in the user interface, and not the kernel:

n = CreateWindow[]

Currently, I'm still stuck. The only option I can think of is to create a standalone Windows service that sits in the background, accepting arrays from the standalone .NET app, and serving them to a Mathematica Notebook on demand (I havn't implemented this yet).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.