Message Boards Message Boards

Using Graphics3D command in C# gives null?

Posted 2 years ago

Why the value of "Images" is always null?
This launches the Mathematica kernel via IKernelLink (the last for including the path to MathKernel):

string[] mlArgs = { "-linkmode", "launch", "-linkname", ViewModelMain.mathKernel };
IKernelLink ml = MathLinkFactory.CreateKernelLink(mlArgs);
MathKernel mk = new MathKernel(ml)
{
   CaptureGraphics = true,             //Get or sets whether this MathKernel object should capture Mathematica graphics output generated during a computation.
  GraphicsFormat = "Automatic",       //Gets or sets the image format for Mathematica graphics generated during a computation.
  UseFrontEnd = false,                //Gets or sets whether the Mathematica notebook front end should be used in the background for graphics rendering services.
   AutoCloseLink = true,
   CaptureMessages = true
};

try

{
  mk.Compute("Graphics3D[Cylinder[{ { 0, 0, 0}, { 0, 0, 1} }, 1], Axes->True]");
  System.Drawing.Image[] Images = mk.Graphics;               //Gets the accumulated Images from Mathematica graphics output during the last call to Compute.
}
POSTED BY: Peter Leibundgut

Sorry, something went wrong with the question!

This code works perfect:

CaptureGraphics = true,
mk.Compute("RevolutionPlot3D[{1, t}, {t, 0,1}]}")

Wolfram.NETLink.MathKernel.Graphics.get zurückgegeben

{System.Drawing.Image[1]}

This code does not return an image, why?

CaptureGraphics = true,
GraphicsFormat = "JPEG",
mk.Compute("Graphics3D[Cylinder[{ { 0, 0, 0}, { 0, 0, 1} }, 1], Axes->True]");

Wolfram.NETLink.MathKernel.Graphics.get zurückgegeben

{System.Drawing.Image[0]}
POSTED BY: Peter Leibundgut
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract