Skip to content

scripting

DaveL17 edited this page Dec 2, 2017 · 20 revisions

Under construction.

The bundle identifier for the Matplotlib plugin is:
com.fogbert.indigoplugin.matplotlib

Experimental Matplotlib Plugin API
The plugin now sports an experimental API that will be expanded over time (and become less experimental over time, too). This can be used by scripters to send data to generate charts. The following is a rudimentary example. All payload elements are required; however, you are not required to specify chart properties through a kwargs element. If you choose not to specify any kwarg properties, you must still send an empty dictionary. One last note, the format of the elements is important. The X and Y values must be presented as lists. The kwargs argument must be presented as a valid dictionary (as does the entire payload). The path argument is the full path where you would like the image to be saved.

#! /usr/bin/env python
# -*- coding: utf-8 -*-

matplotlibPlugin = indigo.server.getPlugin("com.fogbert.indigoplugin.matplotlib")
payload = {'x_values': [1, 2, 3],
           'y_values': [2, 4, 7],
           'kwargs': {'linestyle': 'dashed',
                      'color': 'b',
                      'marker': 'd',
                      'markerfacecolor': 'r'},
           'path':'/Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/images/controls/static/',
           'filename': 'chart_filename1.png'
           }
try:
    result = matplotlibPlugin.executeAction('refreshTheChartsAPI', deviceId=0, waitUntilDone=True, props=payload)
    if result is not None:
        indigo.server.log(result['message'])
except Exception as err:
    indigo.server.log(u"Exception occurred: {0}".format(err))

The return is a dictionary that will contain information about the success/failure of the API call. Presently, there are two items in the return: 'success' and 'message'. 'success' will either be True or False which can be used to detect whether the call to the plugin was a success.

For help interacting with Matplotlib directly, try the matplotlib documentation.

Note that Apple tends to be several versions behind so there will be things in the current version of the matplotlib docs that will be unavailable through the plugin.

Clone this wiki locally