Welcome to Golden Software Support

Grapher 11 Python Automation

Comments

5 comments

  • Avatar
    Katie Yoder

    Yes, Python can be used to automate workflows in Grapher, Surfer, and Voxler including Grapher 11.  However, please note that we do not currently offer any documentation or support for Python automation of our software.

    Please let me know if I can be of further assistance,

    Katie

    0
    Comment actions Permalink
  • Avatar
    gschwepp

    Thank you for your answer, this is nice to hear. Before asking I started playing around with python and grapher. I looked into example scripts for surfer (https://support.goldensoftware.com/hc/en-us/articles/226625748-Do-you-have-an-example-of-automating-Surfer-with-Python-) to figure the syntax myself.    

    In my understanding the api is pretty straight forward and you can relate to most of the objects and method description of the automation help. I got a bug that caused me to assume that python is not supported in Grapher 11.

    Here my script:

    Import win32com.client
    app = win32com.client.Dispatch(“Grapher.Application”)
    app.Visible = True
     
    plot = app.Documents.Add()
    print(type(plot))

    This returns:

    <class ‘str’> 

    A string has no further classes. No Plots can be added to the document. However if I run the same code with Surfer 13:

    Import win32com.client
    app = win32com.client.Dispatch(“Surfer.Application”)
    app.Visible = True
     
    plot = app.Documents.Add()
    print(type(plot))

    It returns:

    <class ‘win32com.client.CDispatch’>

    And I can go on as described in the examples.   

    After some research I hoped to get some information from this link, but the perl script is missing.

    https://support.goldensoftware.com/hc/en-us/articles/230666187-How-can-I-automate-Grapher-using-Perl-

    I would appreciate a hint how I can resolve this issue (just a simple example script would be very nice). But of course I can fully understand that you currently do not do support for Python automation.  Maybe this is actually a bug and I could help a little bit.

    Best

    0
    Comment actions Permalink
  • Avatar
    Katie Yoder

    Thank you for your response.  I'm afraid the only thing I can think of that may be causing a problem with your Grapher script versus the Surfer script is that the Surfer and Grapher automation API's are not identical and perhaps you need to use a graph object in Grapher rather than a plot.  As I said before, our support team does not have any experience with Python and therefore can't offer support of Python scripting.  Perhaps one of our other community members could be more help.

    Regarding the sample script, I have updated the link in the article How can I automate Grapher using Perl so that you can access this script.

    Thanks!

    Katie

    0
    Comment actions Permalink
  • Avatar
    Ruth Rodman

    I had the same problem as gschwepp and found a solution.  Grapher is returning the name of the document created but you want the document object.  You can get it like so:

    Import win32com.client
    app = win32com.client.Dispatch(“Grapher.Application”)
    app.Visible = True
     
    plot = app.Documents.Add() # plot = name of doc object created
    plotDoc = app(plot) # plotDoc = doc object
    1
    Comment actions Permalink
  • Avatar
    gschwepp

    Hi Ruth,

    thank you very much for the solution. I will try it out right away.

    It would be interesting if this works for all Grapher Version or if this is Grapher 11 specific.

    Cheers!

    0
    Comment actions Permalink

Please sign in to leave a comment.