Contour GetGraphicItemByName, GetGraphicItemByType exceptions in all cases - C# automation
Feb 22, 2019 6:21 AM(946 views)
I'm trying to automate the capture of JMP graph images through C#. From what I found through the documentation, the correct way to do this appears to be by getting a handle of the graph with GetGraphicItemByName or GetGraphicItemByType and then SaveGraphicItem.
I found some guidance from this previous post on the subject:
However... it doesn't work for anything I have tried. Everything throws the same unhelpful error which appears to be a native level exception in JMP:
The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
I've tried with both varieties of ByType and ByName using several different objects within the tree. I feel like I must be missing something but I don't know what it could be as the error doesn't give me the slightest clue what is wrong.
JMP.Contour contour = Doc.CreateContourPlot();
int handle = -1;
string errors = string.Empty;
for (int n = 0; n < 11; n++)
string name = "outline box";
case 1: name = "outlinebox"; break;
case 2: name = "Outline Box"; break;
case 3: name = "Outline box"; break;
case 4: name = "outline box"; break;
case 5: name = "framebox"; break;
case 6: name = "FrameBox"; break;
case 7: name = "Frame Box"; break;
case 8: name = "frame box"; break;
case 9: name = "Frame box"; break;
case 10: name = "Framebox"; break;
handle = contour.GetGraphicItemByType(name, 1);
//handle = contour.GetGraphicItemByName(name);
Console.WriteLine("Success with n = " + n);
catch (Exception e)
errors += e.Message + Environment.NewLine;
if (handle == -1) throw new Exception("No handle found, errors: " + Environment.NewLine + errors);
I resolved the issue. Turns out the error was elsewhere in my code. I'm unsure why it threw the error that it did though. The table I provided it didn't have the columns that I expected it to due to another bug in my code. I would have expected that JMP should have caught such a simple error and thrown a more relevant exception which is why I assumed an issue with the function itself.
If anyone else comes across this with a similar issue, be sure to check all other aspect of your input as you can't rely on JMP to report back a meaningful exception...