You are on page 1of 34

4/9/2014 Insight Maker API

https://insightmaker.com/sites/default/files/API/files/API-js.html 1/34
Insight Maker API
Functions to manipulate Insight Maker models.
Introduction
The following is a set of API functions for Insight Maker. JavaScript is the language used for these interfaces. In
addition to the Insight Maker specific functions listed here, standard JavaScript is also supported in buttons.
There are three primary avenues for making use of this API.
For the Action of Buttons embedded within models.
For a parent page to manipulate an embedded IFRAME containing an Insight Maker model.
Using the JavaScript console of the web browser to manipulate a model. To find the built-in JavaScript
console for a web browser, see the relevant browsers documentation.
Primitive Types
A number of the API function refer to primitives by their type. The following are the valid types. Types are usually
quoted when used and should always be capitalized (e.g. Stock).
Stock
Variable
Converter
Flow
Link
Text
Picture
Folder
Button
Ghost
Examples
The following examples illustrate the usage of the API for certain scenarios.
Using Dialogues
Ask the user to specify a URL and opens a new web page at the location.
showURL(showPrompt("What page should I open?"));
Expanding and Collapsing Folders
This example expands all the folders in the model.
expandFolder(findType("Folder"));
And this collapses them.
collapseFolder(findType("Folder"));
Notes
Show the notes for all flow and link primitives in the model.
var connectors = findType(["Flow", "Link"]);
showNote(connectors);
Using Opacity
Makes the currently selected primitives partially transparent.
setOpacity(getSelected(), 50);
Rabbit Birth Rate
This example will work with the default Insight Maker model. It prompts the user to specify the birth rate for the
rabbit population. It then sets the relevant primitive to that value and runs the model.
var birthRate = showPrompt("Enter the birth rate for the rabbits:", 0.1);
var birthPrimitive = findName("Rabbit Birth Rate");
setValue(birthPrimitive, birthRate);
runModel();
This could also be written more compactly as
setValue(findName("Rabbit Birth Rate"), showPrompt("Enter the birth rate for the rabbits:", 0.1));
runModel();
Building a Model
This example creates a new model with two stocks connected by a flow.
Insight Maker API
INDEX
Everything
Classes
Functions
Search
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 2/34
clearModel();
var source = createPrimitive("Source", "Stock", [100, 50], [140, 50]);
setValue(source, 100); //Give the source an initial value of 100
var sink = createPrimitive("Sink", "Stock", [100, 300], [140, 50]);
var myFlow = createConnector("Leakage", "Flow", source, sink);
setValue(myFlow, "0.1*[Source]"); //10% of the source's volume moves to the sink each time period
Manipulating a Model in an IFRAME
To access the API of an embedded IFRAME, first give the IFRAME an id property. This is not added by default in
Insight Maker. For instance change
<IFRAME SRC="...
to
<IFRAME ID="InsightMakerModel1" SRC="...
Then from the parent page you can use the following JavaScript syntax to call API functions. This example calls the
APIs clearModel function.
document.getElementById('InsightMakerModel1').contentWindow.postMessage("clearModel()", "*");
Summary
Insight Maker API Functions to manipulate Insight Maker models.
DIALOGUES AND USER INPUT
showMessage Shows a message in a dialogue window.
showPrompt Shows a prompt in a dialogue window and provides a text input for the
user to enter a value.
showChoice Shows a prompt in a dialogue window and provides the user the option
to click OK or Cancel.
showURL Creates a new web browser window and sets the URL.
showData Creates a display to showcase data.
frontWindow Gets the frontmost window (if one exists).
closeAllWindows Closes all open windows.
openFile Prompts the user to select one or more files on their computer.
GENERAL MODEL FUNCTIONS
runModel Runs a simulation and optionally returns the results.
saveModel Saves the model.
clearModel Removes all primitives from the model.
layoutModel Reorganizes the primitives in the model according to an algorithm.
setZoom Sets the scale of the diagram display.
SIMULATION SETTINGS
getTimeStep Gets the time step used in the simulation.
setTimeStep Sets the time step used in the simulation.
getTimeStart Gets the start time for the simulation.
setTimeStart Sets the start time for the simulation.
getTimeLength Gets the length of the simulation.
setTimeLength Sets the length of the simulation.
getPauseInterval Gets the intervals at which to pause the simulation.
setPauseInterval Sets the intervals at which to pause the simulation.
getTimeUnits Gets the time units of the simulation.
setTimeUnits Sets the time units of the simulation.
getAlgorithm Gets the algorithm for the simulation.
setAlgorithm Sets the algorithm of the simulation.
getMacros Gets the macros for the insight.
setMacros Sets the macros of the insight.
FINDING AND ACCESSING SPECIFIC
PRIMITIVES
findName Finds and returns a primitive by its name.
findAll Finds and returns all primitives in the model.
findType Finds and returns all primitives of a specific type.
findID Finds and returns a primitive using its ID.
findValue Finds and returns all primitives whose values match a regular expression.
findNote Finds and returns all primitives whose notes match a regular expression.
CREATE AND DELETE PRIMITIVES
createPrimitive Creates a new primitive and adds it to the model.
createConnector Creates a new connector primitive and adds it to the model.
removePrimitive Removes a primitive from the model.
PRIMITIVE SELECTIONS
highlight Highlights a single primitive.
getSelected Finds and returns the currently selected primitives.
setSelected Sets the currently selected primitives.
isSelected Indicates whether a primitive is selected.
GENERAL PRIMITIVE FUNCTIONS
getID Gets the ID of the passed primitive.
getType Gets the type of the passed primitive.
getName Gets the name of the passed primitive.
setName Sets the name of the passed primitive.
getUnits Gets the units of the passed primitive.
setUnits Sets the units of the passed primitive.
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 3/34
getConstraints Gets the upper and lower bounds on the passed primitive to test against
during simulation.
setConstraints Sets the upper and lower bounds on the passed primitive to test against
during simulation.
getNote Gets the note of the passed primitive.
setNote Sets the note of the passed primitive.
showNote Shows the note for the passed primitive.
hideNote Hides the note for the passed primitive.
showEditor Shows the value editor for the passed primitive.
getValue Gets the value of the passed primitive.
setValue Sets the value of the passed primitive.
getSize Gets the size of the passed primitive.
getPosition Gets the position of the passed primitive.
setPosition Sets the position of the passed primitive.
PRIMITIVE STYLING FUNCTIONS
getOpacity Gets the opacity of the passed primitive.
setOpacity Sets the opacity of the passed primitive.
getLineColor Gets the line color of the passed primitive.
setLineColor Sets the line color of the passed primitive.
getFontColor Gets the font color of the passed primitive.
setFontColor Sets the font color of the passed primitive.
getFillColor Gets the fill color of the passed primitive.
setFillColor Sets the fill color of the passed primitive.
getImage Gets the image of the passed primitive.
setImage Sets the image of the passed primitive.
STOCKS
getNonNegative Gets the non-negative property of stocks (also applicable to flows).
setNonNegative Sets the non-negative value of the passed stocks (also applicable to
flows).
getStockType Gets the type of the stock.
setStockType Sets the type of the passed stock.
getDelay Gets the delay length of conveyor stocks.
setDelay Sets the delay length of the passed conveyor stock.
CONNECTORS See getNonNegative and setNonNegative for setting the only-positive
property of flows.
getEnds Gets the alpha and omega for the connector
setEnds Sets the alpha and omega for a connector.
connected Determines two primitives are connected by a link, flow, or transition.
STATES
getResidency Gets the residency property of a state primitive.
setResidency Sets the residency property of a state primitive.
TRANSITIONS AND ACTIONS
getTriggerType Gets the trigger type of a transition or action.
setTriggerType Sets the trigger type for a transition or action.
getTriggerValue Gets the trigger value equation of a transition or action.
setTriggerValue Sets the trigger value for a transition or action.
getTriggerRepeat Gets the trigger Repeat property of a transition or action.
setTriggerRepeat Sets the trigger Repeat property for a transition or action.
getTriggerRecalculate Gets the trigger Recalculate property of a transition or action.
setTriggerRecalculate Sets the trigger Recalculate property for a transition or action.
CONVERTERS
getData Gets the data of a converter.
setData Sets the data of a converter.
getConverterInput Gets the input source of a converter.
setConverterInput Sets the input source of a converter.
getInterpolation Gets the interpolation mode of a converter.
setInterpolation Sets the interpolation mode of a converter.
BUTTONS
pressButton Simulates a press of the passed button(s) firing its action.
AGENTS
getPopulationSize Gets the size of the agent population.
setPopulationSize Sets the size of the agent population.
getAgentBase Gets the base agent for the population.
setAgentBase Sets the base agent for the population.
getGeometryWrap Whether the geometry should wrap across edges.
setGeometryWrap Sets the wrap property for the population area geometry.
getGeometryUnits Gets the units for the population area geometry.
setGeometryUnits Sets the units for the population area geometry.
getGeometryWidth Gets the width for the population area geometry.
setGeometryWidth Sets the width for the population area geometry.
getGeometryHeight Gets the height for the population area geometry.
setGeometryHeight Sets the height for the population area geometry.
getAgentPlacement The placement method for the agent population.
setAgentPlacement Sets the placement method for the agent population.
getAgentPlacementFunction A custom placement function for the agent population.
setAgentPlacementFunction Sets the custom placement function for the agent population.
getAgentNetwork The network method for the agent population.
setAgentNetwork Sets the network method for the agent population.
getAgentNetworkFunction A custom network function for the agent population.
setAgentNetworkFunction Sets the custom network function for the agent population.
FOLDERS
collapseFolder Collapses a folder or an array of folders.
expandFolder Expands a folder or an array of folders.
getCollapsed Returns whether or not a given folder is collapsed.
getParent Gets the parent folder for a primitive.
setParent Sets the parent folder for a primitive.
getChildren Returns the children of a folder.
getFolderType Gets the type of a folder.
setFolderType Sets the type of a folder.
getFolderAgentParent Gets the agent parent of a folder.
setFolderAgentParent Sets the agent parent of a folder.
getFolderSolver
setFolderSolver Sets the solver object for a folder
UTILITY FUNCTIONS
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 4/34
excludeType Removes a specific type of primitive from an array of primitives.
primitiveIndex Locates the index of a specific primitive in an array of primitives.
uniquePrimitives Returns the passed array with duplicated primitives removed
setGlobal Sets the value of a global variable.
getGlobal Gets the value of a global variable.
INSIGHT MAKER INTERFACE
topBarShown Determines whether or not the Insight Maker top toolbar (which contains
the Run Simulation button and other tools) is currently shown.
toggleTopBar Toggles the visibility of the top toolbar.
sideBarShown Determines whether or not the Insight Maker side panel (which contains
parameter sliders and information about the selected primitive) is
currently shown.
toggleSideBar Toggles the visibility of the side panel.
updateSideBar Refreshes the values in the side panel to reflect any changes in the
model.
DIALOGUES AND USER INPUT
showMessage
function showMessage(message)
Shows a message in a dialogue window.
Parameters
message The string to show as the message.
See also
showPrompt, showChoice
showPrompt
function showPrompt(message,
defaultValue)
Shows a prompt in a dialogue window and provides a text input for the user to enter a value.
Parameters
message The string to show as the prompt.
defaultValue The default value for the prompt. This parameter is optional.
Returns
The value entered by the user.
See also
showMessage, showChoice
showChoice
function showChoice(message)
Shows a prompt in a dialogue window and provides the user the option to click OK or Cancel. Returns the value
the user clicked as a boolean.
Parameters
message The string to show as the prompt.
Returns
The value of the button clicked by the user as a boolean. OK is true, Cancel is false.
See also
showMessage, showPrompt
showURL
function showURL(url)
Creates a new web browser window and sets the URL.
Parameters
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 5/34
url The URL to show.
showData
function showData(title,
tabs,
size )
Creates a display to showcase data. Multiple tabs of data may be shown. This function is passed an array of
objects each representing an individual tab.
Parameters
title The title for the data window
tabs An array of tab objects
size The dimensions of the window in the form [width, height] (optional)
Tab Objects
Each tab object contains several properties.
name The name of the tab
type The tab type. E.g. text, HTML, table or chart
data The data for the tab
The different types of tabs are as follows.
Text Tab
A text tab displays a large amount of text. For a text tab, the data property should be the text string that will be
displayed.
HTML Tab
An HTML tab displays HTML content. For an HTML tab, the data property should be the HTML content that will be
displayed.
Table Tab
A table tab displays a grid of data. For a table tab, the data object should be an array of arrays. Each inner array
represents a column in the resulting table. The following property is also supported for tables.
header For a table, an array containing containing the titles of the columns (optional)
Chart Tab
A chart creates a graphical display of your data. In this case the data should be an array of series objects.
The following property is also supported.
xData The x coordinates for the series (each series must have the same number of points with
the same x-coordinates). In the form [x1, x2, ..., xn]
xType The data type for the x-axis can be numeric or category (for use with categorical
data such as column charts). By default, numeric data is assumed. (optional)
xLabel A string for the x-Axis label (optional)
yLabel A string for the y-Axis label (optional)
legend A string controlling the position of the legend. Can be left, right, bottom, top, or
none (optional)
verticalGrid True/false value whether or not to plot a vertical grid (optional)
horizontalGird True/false value whether or not to plot a horizontal grid (optional)
Each series object has the following the properties
data An array containing the data for the series of the form [y1, y2, ..., yn]
type The display type for the series. Can be line or bar
name The series name as a string (for display in the legend)
color The color of the series. A string such as green or #00ff00 (optional)
hideLegend Prevents the series from being displayed in the legend (optional)
fill If the series is a line series, creates a solid filled area between the line and the x-axis
(optional)
hideMarkers Hides the markers for individual data points (optional)
Returns
The window object that was created.
Example
showData("Sample Data",
[
{name: "A Chart",
type: "chart",
xLabel: "Chart x-Axis",
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 6/34
yLabel: "Chart y-Axis",
legend: "top",
horizontalGrid: true,
verticalGrid: true,
xType: "numeric",
xData: [1,2,3,4,5],
data: [{
data: [1,4,9,16,25],
type: "line",
name: "Energy"
},{
data: [1,2,3,4,5],
type: "line",
name: "Cost"
}]
},
{name: "I'm a Text Tab",
type: "text",
data: "This is a long data string..."
},
{name: "I'm an HTML Tab",
type: "html",
data: "<center><p>This is <b>HTML</b> content.</p></center>"
},
{name: "Here's a Grid",
type: "table",
data: [[1,2,3,4],[1,4,9,16]],
header: ["Value", "Value^2"]
}
]
)
frontWindow
function frontWindow()
Gets the frontmost window (if one exists).
Returns
A window object.
closeAllWindows
function closeAllWindows()
Closes all open windows.
openFile
function openFile(config)
Prompts the user to select one or more files on their computer. Information about the selected files are made
available and the contents of the files are optionally read into memory.
Note that this function needs to be called as a direct result of user actions (such as the user clicking on a button).
Browser security restrictions will prevent the function from operating if it is not called in response a user actions. Note
also that this function is not supported on Internet Explorer 9.
Parameters
config A configuraiton object with the following optional properties:
multiple If false, only a single file may be selected; if true, one or more files may be selected at a
time.
accept A string containing a MIME file type to filter file selection. If defined, only files matching the
specified type may be selected. For example, image/* may be used to only accept image
files.
read If defined the selected files will be opened and their contents loaded. Read may either be
binary in which case the contents is loaded as a binary string, text in which case the
contents is loaded as a regular text string, or xlsx in which case an Excel file is loaded as an
object.
onCompleted A function to handle results. The openFile function is asynchronous. Once it completes, the
callback function is called with the resulting data as a parameter.
onError A function to handle the occurence of an error.
onSelected A function fired once files have been selected but before data has been read.
Returns
The openFile function is asynchronous and returns nothing directly. On the successful selection of files, the callback
is called with the results.
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 7/34
If config.multiple is false, these results are a single file object. If config.multiple is true, then these results are
an array of file objects. Each file object has the following properties
file The orginal file object.
name The name of the selected file.
type The type of the selected file.
size The size of the selected file.
contents If config.read is true, the contents in the file is loaded with the specified type.
Examples
// Select a single text file and display its contents
openFile({
read: "text",
multiple: false,
onCompleted: function(result){
alert(result.contents);
}
});
GENERAL MODEL FUNCTIONS
runModel
function runModel(config)
Runs a simulation and optionally returns the results.
Parameters
config A configuration object. For compatibility, if set to the Boolean value,
equivalent to calling runModel with a configuration object with the silent
property set to the boolean value.
config.silent If false or undefined, behaves the same way as if the user clicked the run
simulation button. If true, no visible response is shown to running the
simulation and the results of the simulation are returned as an object.
config.onSuccess(results) Callback called when the simulation completes successfully.
config.onError(results) Callback called when an error occurs during the simulation.
Returns
If silent is true, returns the simulation results as a results object. If callbacks are defined, the callbacks are called
with a results object. This object contains the following properties.
times The times for each period of the simulation as an array.
value(primitive) A function that takes a primitive reference and returns an array of the values that
primitive took on over the course of the simulation.
lastValue(primitive) A function that takes a primitive reference and returns the last value of the
primitive during the simulation.
window The results window object (if config.silent is false).
error none if no simulation error occurred, otherwise an error message.
errorPrimitive The primitive that caused the error.
Examples
# Runs a simulation, and displays the average value of the Stock named "Rabbits"
runModel({
onSuccess: function(results){
var sum = 0;
for(var i = 0; i < results.times.length; i++){
sum += results.value(findName("Rabbits"))[i];
}
showMessage("The average value is: " + sum/results.times.length);
}
})
saveModel
function saveModel(dialogue)
Saves the model.
Parameters
dialogue Pass true to show the properties dialogues (e.g. name, description, tags). The dialogue is
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 8/34
always shown if this is the first save.
clearModel
function clearModel()
Removes all primitives from the model.
layoutModel
function layoutModel(algorithm)
Reorganizes the primitives in the model according to an algorithm.
Parameters
algorithm The algorithm used to calculate the new positions of the primitive. Either organic or circular.
setZoom
function setZoom(scale)
Sets the scale of the diagram display.
Parameters
scale The diagram scale. If this is a number, then it determine the scale level. 1 means 100%, 0.5 means
50%, 2 means 200% and so on. You also pass one of the following strings: fit to fit the model to
the diagram area, actual to reset the scale, in to zoom further in based on the current scale, and
out to further out based on the current scale.
SIMULATION SETTINGS
getTimeStep
function getTimeStep()
Gets the time step used in the simulation.
Returns
The time step for the simulation as a floating point number.
See also
setTimeStep
setTimeStep
function setTimeStep(timeStep)
Sets the time step used in the simulation.
Parameters
timeStep The time step to be used in the simulation.
See also
getTimeStep
getTimeStart
function getTimeStart()
Gets the start time for the simulation.
Returns
The start time for the simulation as a floating point number.
See also
setTimeStart
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 9/34
setTimeStart
function setTimeStart(timeStart)
Sets the start time for the simulation.
Parameters
timeStart The start time for the simulation.
See also
getTimeStart
getTimeLength
function getTimeLength()
Gets the length of the simulation.
Returns
The length of the simulation as a floating point number.
See also
setTimeLength
setTimeLength
function setTimeLength(timeLength)
Sets the length of the simulation.
Parameters
timeLength The length of the simulation.
See also
getTimeLength
getPauseInterval
function getPauseInterval()
Gets the intervals at which to pause the simulation.
Returns
The pause interval as a floating point number. Returns undefined if a pause interval has not been specified.
See also
setPauseInterval
setPauseInterval
function setPauseInterval(pauseInterval)
Sets the intervals at which to pause the simulation.
Parameters
pauseInterval The pause interval for the simulation.
See also
setPauseInterval
getTimeUnits
function getTimeUnits()
Gets the time units of the simulation.
Returns
The time units of the simulation (e.g. Seconds, Minutes, Days, Years).
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 10/34
See also
setTimeUnits
setTimeUnits
function setTimeUnits(units)
Sets the time units of the simulation.
Parameters
units The time units of the simulation (e.g. Seconds, Minutes, Days, Years).
See also
getTimeUnits
getAlgorithm
function getAlgorithm()
Gets the algorithm for the simulation.
Returns
The algorithm for the simulation as a string. RK1 indicates Eulers method. RK4 indicates a 4th order Runge-Kutta
method.
See also
setAlgorithm
setAlgorithm
function setAlgorithm(algorithm)
Sets the algorithm of the simulation.
Parameters
algorithm The algorithm for the simulation. RK1 indicates Eulers method. RK4 indicates a 4th order
Runge-Kutta method.
See also
getAlgorithm
getMacros
function getMacros()
Gets the macros for the insight.
Returns
The macros for the insight as a string.
See also
setMacros
setMacros
function setMacros(macros)
Sets the macros of the insight.
Parameters
macros The macros for the insight.
See also
getMacros
FINDING AND ACCESSING SPECIFIC PRIMITIVES
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 11/34
findName
function findName(name)
Finds and returns a primitive by its name. If more than one primitive with the same name exists, returns an array of
primitives.
Parameters
name The name of the primitive to return as a string. Also accepts an array of strings in which case all the
primitives named in the array will be returned.
Return
A primitive. If multiple primitives exist with the same name, an array of primitives will be returned. Returns null if no
primitives are found.
See also
findType, findAll, findID, findNote, findValue
findAll
function findAll()
Finds and returns all primitives in the model.
Return
An array of primitives.
See also
findName, findType, findID, findNote, findValue
findType
function findType(type)
Finds and returns all primitives of a specific type.
Parameters
type The type of primitives to return. For instance: Stock, Flow, Link, Text, Button, Picture,
Converter or Variable. An array of type strings may also be passed.
Return
An array of primitives of the specified type.
See also
findName, findAll, findID, findNote, findValue
findID
function findID(id)
Finds and returns a primitive using its ID.
Parameters
ID The ID of the primitive to find. May also be an array of IDs.
Return
A primitive. If an array of IDs was passed, returns an array of primitives.
See also
findName, findType, findAll, findValue, findNote, getID
findValue
function findValue(search)
Finds and returns all primitives whose values match a regular expression.
Parameters
search The regular expression to search for. Can also be a string in which case the primitive values will be
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 12/34
tested for strict case-sensitive equality against the string. May also be an array of regular
expressions and strings in which case any primitive with a value that matches one element of the
array will be returned.
Return
An array of primitives whose values match the regular expression. Returns an empty array if no primitives match.
Example
// Returns all primitives that use the log function
var containingLog = findValue(/log\(/i);
// Returns all primitives whose value is strictly "1"
var isOne = findValue("1");
See also
findName, findType, findAll, findNote, getID
findNote
function findNote(search)
Finds and returns all primitives whose notes match a regular expression.
Parameters
search The regular expression to search for. Can also be a string in which case the primitive notes will be
tested for strict case-sensitive equality against the string. May also be an array of regular
expressions and strings in which case any primitive with a note that matches one element of the
array will be returned.
Return
An array of primitives whose notes match the regular expression. Returns an empty array if no primitives match.
See also
findName, findType, findAll, findValue, getID
CREATE AND DELETE PRIMITIVES
createPrimitive
function createPrimitive(name,
type,
position,
size )
Creates a new primitive and adds it to the model. This function is only for node-type primitives not connectors (e.g.
flows or links).
Parameters
name The name of the primitive to add.
type The type of the primitive to add. For example, Variable or Stock.
position The location of the upper-left corner of the primitive in the form: [x, y].
size The dimensions of the primitive in the form: [width, height].
Return
The newly created primitive.
See also
createConnector, removePrimitive
createConnector
function createConnector(name,
type,
alpha,
omega )
Creates a new connector primitive and adds it to the model.
Parameters
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 13/34
name The name of the primitive to add.
type The type of the primitive to add: Link or Flow.
alpha The primitive that will be at the start of the connector.
omega The primitive that will be at the end of the connector.
Return
The newly created connector primitive.
See also
createPrimitive, removePrimitive
removePrimitive
function removePrimitive(primitive)
Removes a primitive from the model. You should not attempt to access or modify a primitive once it has been
removed.
Parameters
primitive The primitive to delete, can also be an array of primitives.
See also
createPrimitive, createConnector
PRIMITIVE SELECTIONS
highlight
function highlight(primitive)
Highlights a single primitive. Selects the primitive, expands any collapsed folders the primitive is in, and scrolls to the
position of the primitive.
Parameters
primitive The primitive to highlight.
getSelected
function getSelected()
Finds and returns the currently selected primitives.
Return
An array of the selected primitives.
See also
setSelected, isSelected
setSelected
function setSelected(primitives)
Sets the currently selected primitives.
Parameters
primitives An array of primitives to select. Can also be a single primitive.
See also
getSelected, isSelected
isSelected
function isSelected(primitive)
Indicates whether a primitive is selected.
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 14/34
Parameters
primitive A primitive to return the selection status for. May also be an array of primitives.
Return
Whether the primitive is selected or not as a boolean. If an array of primitives was passed to the function, an array
of booleans is returned.
See also
getSelected, setSelected
GENERAL PRIMITIVE FUNCTIONS
getID
function getID(primitive)
Gets the ID of the passed primitive. The ID remains constant even if the name of a primitive changes. The ID is a
string.
Parameters
primitive The primitive for which the ID is requested. May also be an array of primitives.
Return
The ID of the primitive as a string. If an array of primitives was passed, returns an array of IDs.
See also
findID
getType
function getType(primitive)
Gets the type of the passed primitive.
Parameters
primitive The primitive for which the type is requested. May also be an array of primitives.
Return
The type of the primitive as a string. If an array of primitives was passed, returns an array of IDs.
getName
function getName(primitive)
Gets the name of the passed primitive.
Parameters
primitive The primitive for which the name is requested. May also be an array of primitives.
Return
The name of the primitive as a string. If an array of primitives was passed, returns an array of names.
See also
setName
setName
function setName(primitive,
name )
Sets the name of the passed primitive.
Parameters
primitive The primitive for which the name will be set. May also be an array of primitives in which case
they will all be set to the same name.
name The new name for the primitive.
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 15/34
See also
getName
getUnits
function getUnits(primitive)
Gets the units of the passed primitive.
Parameters
primitive The primitive for which the units are requested. May also be an array of primitives.
Return
The units of the primitive as a string. If an array of primitives was passed, returns an array of units.
See also
setUnits
setUnits
function setUnits(primitive,
units )
Sets the units of the passed primitive.
Parameters
primitive The primitive for which the units will be set. May also be an array of primitives in which case
they will all be set to the same units.
units The new units for the primitive.
See also
getUnits
getConstraints
function getConstraints(primitive)
Gets the upper and lower bounds on the passed primitive to test against during simulation.
Parameters
primitive The primitive for which the constraints are requested. May also be an array of primitives.
Return
The constraints of the primitive as an array. The format is [MinimumConstraint, MinimumConstraintMode,
MaximumConstraint, MaximumConstraintMode]. Constraint mode is false to disable the constraint and true to enable it.
See also
setConstraints
setConstraints
function setConstraints(primitive,
constraints)
Sets the upper and lower bounds on the passed primitive to test against during simulation.
Parameters
primitive The primitive for which the units will be set. May also be an array of primitives in which case
they will all be set to the same constraints.
constraints The constraints of the primitive as an array. The format is [MinimumConstraint,
MinimumConstraintMode, MaximumConstraint, MaximumConstraintMode]. Constraint mode is
false to disable the constraint and true to enable it.
See also
getConstraints
getNote
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 16/34
function getNote(primitive)
Gets the note of the passed primitive.
Parameters
primitive The primitive for which the note is requested. May also be an array of primitives.
Return
The note of the primitive as a string. If an array of primitives was passed, returns an array of notes.
See also
setNote
setNote
function setNote(primitive,
note )
Sets the note of the passed primitive.
Parameters
primitive The primitive for which the note will be set. May also be an array of primitives in which case
they will all be set to the same note.
note The new note for the primitive.
See also
getNote
showNote
function showNote(primitive)
Shows the note for the passed primitive. The note is shown as a closable tooltip next to the primitive. If the note is
empty, the note will not be shown.
Parameters
primitive The primitive for which the note will be shown. May also be an array of primitives in which case
they will all have their notes shown.
See also
hideNote
hideNote
function hideNote(primitive)
Hides the note for the passed primitive. The note is shown as a closable tooltip next to the primitive.
Parameters
primitive The primitive for which the note will be hidden. May also be an array of primitives in which case
they will all have their notes hidden.
See also
showNote
showEditor
function showEditor(primitive)
Shows the value editor for the passed primitive.
Parameters
primitive The primitive for which the editor will be shown.
getValue
function getValue(primitive)
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 17/34
Gets the value of the passed primitive. The value depends on the type of the primitive. For instance, the value of
stock is its initial value while the value of a flow is its rate.
Parameters
primitive The primitive for which the value is requested. May also be an array of primitives.
Return
The value of the primitive as a string. If an array of primitives was passed, returns an array of values.
See also
setValue
setValue
function setValue(primitive,
value )
Sets the value of the passed primitive. The value depends on the type of the primitive. For instance, the value of
stock is its initial value while the value of a flow is its rate.
Parameters
primitive The primitive for which the value will be set. May also be an array of primitives in which case
they will all be set to the same value.
value The new value for the primitive. Can be a number or a string.
See also
getValue
getSize
function getSize(primitive)
Gets the size of the passed primitive.
Parameters
primitive The primitive for which the position is requested. May also be an array of primitives.
Return
The size as an array of the form: [width, height].
getPosition
function getPosition(primitive)
Gets the position of the passed primitive.
Parameters
primitive The primitive for which the position is requested. May also be an array of primitives.
Return
The position as an array of the form [x, y]. The position is measured from the top-left corner of the graph.
See also
setPosition
setPosition
function setPosition(primitive,
position )
Sets the position of the passed primitive.
Parameters
primitive The primitive for which the position will be set. May also be an array of primitives in which case
they will all be set to the same position.
position The new position for the primitive in the form [x, y]. The position is measured from the top-left
corner of the graph.
See also
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 18/34
getPosition
PRIMITIVE STYLING FUNCTIONS
getOpacity
function getOpacity(primitive)
Gets the opacity of the passed primitive. Opacity is a value between 0 (invisible) to 100 (fully opaque).
Parameters
primitive The primitive for which the opacity will be returned. May also be an array of primitives.
Return
The opacity of the primitive
setOpacity
function setOpacity(primitive,
opacity )
Sets the opacity of the passed primitive. Opacity is a value between 0 (invisible) to 100 (fully opaque).
Parameters
primitive The primitive for which the opacity will be set. May also be an array of primitives in which case
they will all be set to the same opacity.
opacity The new opacity for the primitive.
getLineColor
function getLineColor(primitive)
Gets the line color of the passed primitive.
Parameters
primitive The primitive for which the line color will be returned. May also be an array of primitives.
Return
The line color of the primitive
setLineColor
function setLineColor(primitive,
lineColor )
Sets the line color of the passed primitive.
Parameters
primitive The primitive for which the line color will be set. May also be an array of primitives in which
case they will all be set to the same color.
lineColor The new line color for the primitive.
getFontColor
function getFontColor(primitive)
Gets the font color of the passed primitive.
Parameters
primitive The primitive for which the font color will be returned. May also be an array of primitives.
Return
The font color of the primitive
setFontColor
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 19/34
function setFontColor(primitive,
fontColor )
Sets the font color of the passed primitive.
Parameters
primitive The primitive for which the font color will be set. May also be an array of primitives in which
case they will all be set to the same color.
fontColor The new font color for the primitive.
getFillColor
function getFillColor(primitive)
Gets the fill color of the passed primitive.
Parameters
primitive The primitive for which the fill color will be returned. May also be an array of primitives.
Return
The fill color of the primitive
setFillColor
function setFillColor(primitive,
fillColor )
Sets the fill color of the passed primitive.
Parameters
primitive The primitive for which the fill color will be set. May also be an array of primitives in which case
they will all be set to the same color.
fillColor The new fill color for the primitive.
getImage
function getImage(primitive)
Gets the image of the passed primitive.
Parameters
primitive The primitive for which the image will be returned. May also be an array of primitives.
Return
The image of the primitive as a string
setImage
function setImage(primitive,
image )
Sets the image of the passed primitive.
Parameters
primitive The primitive for which the image will be set. May also be an array of primitives in which case
they will all be set to the same image.
image The image url or alias as a string.
STOCKS
getNonNegative
function getNonNegative(primitive)
Gets the non-negative property of stocks (also applicable to flows). A non-negative stock will never become
negative.
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 20/34
Parameters
primitive The stock for which the value is requested. May also be an array of stock.
Return
The non-negative value of the stock. If an array of primitives was passed, returns an array of values.
See also
setNonNegative
setNonNegative
function setNonNegative(primitive,
nonNegative)
Sets the non-negative value of the passed stocks (also applicable to flows).
Parameters
primitive The stock for which the non-negative value will be set. May also be an array of stocks in
which case they will all be set to the same value.
nonNegative The new non-negative status for the stock. Either true or false.
See also
getNonNegative
getStockType
function getStockType(primitive)
Gets the type of the stock. The type affects the behavior of the stock and may either be Store (the default) or
Conveyor.
Parameters
primitive The stock for which the type is requested. May also be an array of stocks.
Return
The type of the stock as a string. If an array of stocks was passed, returns an array of strings.
See also
setStockType
setStockType
function setStockType(primitive,
type )
Sets the type of the passed stock.
Parameters
primitive The stock for which the type will be set. May also be an array of stocks in which case they will
all be set to the same type.
type The type of the stock as a string. Either Store (the default) or Conveyor.
See also
getStockType
getDelay
function getDelay(primitive)
Gets the delay length of conveyor stocks.
Parameters
primitive The stock for which the value is requested. May also be an array of stocks.
Return
The delay length of the stock. If an array of stocks was passed, returns an array of lengths.
See also
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 21/34
setDelay
setDelay
function setDelay(primitive,
delay )
Sets the delay length of the passed conveyor stock.
Parameters
primitive The stock for which the delay length will be set. May also be an array of stocks in which case
they will all be set to the same value.
delay The delay length for the stock.
See also
getDelay
CONNECTORS
See getNonNegative and setNonNegative for setting the only-positive property of flows.
getEnds
function getEnds(connector)
Gets the alpha and omega for the connector
Parameters
connector The connector for which the ends are requested. Can also be an array of connectors.
Return
The alpha and omega as an array: [alpha, omega]. Array elements are returned as null if no connection exists.
See also
setEnds
setEnds
function setEnds(connector,
ends )
Sets the alpha and omega for a connector.
Parameters
connector The connector for which the alpha and omega will be set. May also be an array of connectors.
ends The new alpha and omega for the connector as an array: [alpha, omega]. Use null for either
alpha or omega to disconnect an end.
See also
getEnds
connected
function connected(primitive1,
primitive2 )
Determines two primitives are connected by a link, flow, or transition. Alternatively if one of the primitives is a
connector, checks if it connects directly to the other primitive.
Parameters
primitive1 A primitive.
primitive2 A primitive to test whether it is connected to primitive1.
Return
A boolean. True if the primitives are connected, false otherwise.
STATES
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 22/34
getResidency
function getResidency(state)
Gets the residency property of a state primitive.
Parameters
state The state for which the residency property is requested. May also be an array of states.
Return
The residency property as a string.
See also
setResidency
setResidency
function setResidency(state,
residency)
Sets the residency property of a state primitive.
Parameters
state The state primitive for which the residency property will be set. May also be an array of states.
residency The new value for the residency property.
See also
getResidency
TRANSITIONS AND ACTIONS
getTriggerType
function getTriggerType(primitive)
Gets the trigger type of a transition or action.
Parameters
primitive The transition or action for which the trigger is requested. May also be an array of transitions
or actions.
Return
The trigger mode as a string. May be Timeout, Probability or Condition.
See also
setTriggerType
setTriggerType
function setTriggerType(primitive,
trigger )
Sets the trigger type for a transition or action.
Parameters
primitive The transition or action for which the trigger will be set. May also be an array of transitions or
actions.
trigger The new trigger for the transition or action. May be Timeout Probability or Condition.
See also
getTriggerType
getTriggerValue
function getTriggerValue(primitive)
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 23/34
Gets the trigger value equation of a transition or action.
Parameters
primitive The transition or action for which the trigger value equation is requested. May also be an array
of transitions or actions.
Return
The trigger value equation as a string.
See also
setTriggerValue
setTriggerValue
function setTriggerValue(primitive,
value )
Sets the trigger value for a transition or action.
Parameters
primitive The transition or action for which the trigger will be set. May also be an array of transitions or
actions.
value The new trigger value equation as a string.
See also
getTriggerValue
getTriggerRepeat
function getTriggerRepeat(primitive)
Gets the trigger Repeat property of a transition or action.
Parameters
primitive The transition or action for which the property is requested. May also be an array of transitions
or actions.
Return
The trigger Repeat property as a boolean.
See also
setTriggerRepeat
setTriggerRepeat
function setTriggerRepeat(primitive,
repeat )
Sets the trigger Repeat property for a transition or action.
Parameters
primitive The transition or action for which the Repeat property will be set. May also be an array of
transitions or actions.
repeat A boolean determining whether to repeat the trigger
See also
getTriggerRepeat
getTriggerRecalculate
function getTriggerRecalculate(primitive)
Gets the trigger Recalculate property of a transition or action.
Parameters
primitive The transition or action for which the property is requested. May also be an array of transitions
or actions.
Return
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 24/34
The trigger Recalculate property as a boolean.
See also
setTriggerRecalculate
setTriggerRecalculate
function setTriggerRecalculate(primitive,
recalculate)
Sets the trigger Recalculate property for a transition or action.
Parameters
primitive The transition or action for which the Recalculate property will be set. May also be an array
of transitions or actions.
recalculate A boolean determining whether to recalculate each time step
See also
getTriggerRecalculate
CONVERTERS
getData
function getData(converter)
Gets the data of a converter.
Parameters
converter The converter for which the data is requested. May also be an array of Converters.
Return
The Converter data as a string. A set of input/output pairs separated by semicolons. Example data form:
1,1;2,4;3,9
See also
setData
setData
function setData(converter,
data )
Sets the data of a converter.
Parameters
converter The converter for which the data will be set. May also be an array of Converters in which case
they will all be set to the same value.
data The data for the converter as a string. A set of input/output pairs separated by semicolons.
Example data form: 1,1;2,4;3,9
See also
getData
getConverterInput
function getConverterInput(converter)
Gets the input source of a converter.
Parameters
converter The converter for which the input source is requested. May also be an array of Converters.
Return
The input source. If the input source is a primitive, returns the primitive. Otherwise returns null (indicating the use
of time as the input source).
See also
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 25/34
<setInputSource>
setConverterInput
function setConverterInput(converter,
input )
Sets the input source of a converter.
Parameters
converter The converter for which the input source will be set. May also be an array of Converters in
which case they will all be set to the same value.
input The input source. Pass either a primitive or use null to indicate the usage of time as the input.
See also
getConverterInput
getInterpolation
function getInterpolation(converter)
Gets the interpolation mode of a converter.
Parameters
converter The converter for which the interpolation is requested. May also be an array of Converters.
Return
The interpolation mode as a string. May be Linear or Discrete.
See also
setInterpolation
setInterpolation
function setInterpolation(converter,
interpolation)
Sets the interpolation mode of a converter.
Parameters
converter The converter for which the interpolation will be set. May also be an array of Converters in
which case they will all be set to the same value.
interpolation The interpolation mode for the converter as a string. May either be Linear or Discrete.
See also
getInterpolation
BUTTONS
pressButton
function pressButton(button)
Simulates a press of the passed button(s) firing its action. Can be useful for chaining together methods.
Parameter
button The button to be pressed. Can also be an array of buttons.
AGENTS
getPopulationSize
function getPopulationSize(agents)
Gets the size of the agent population.
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 26/34
Parameters
agents The agent population for which the size will be returned. May also be an array of agent
populations.
Return
The population size.
See also
setPopulationSize
setPopulationSize
function setPopulationSize(agents,
size )
Sets the size of the agent population.
Parameters
agents The agent population for which the size will be set. May also be an array of agent populations.
size The new population size.
See also
getPopulationSize
getAgentBase
function getAgentBase(agents)
Gets the base agent for the population.
Parameters
agents The agent population for which the base agent will be returned. May also be an array of agent
populations.
Return
The base agent folder.
See also
setAgentBase
setAgentBase
function setAgentBase(agents,
folder )
Sets the base agent for the population.
Parameters
agents The agent population for which the base agent will be set. May also be an array of agent
populations.
folder The base agent folder. The type for this folder should be set to Agent.
See also
getAgentBase
getGeometryWrap
function getGeometryWrap(agents)
Whether the geometry should wrap across edges.
Parameters
agents The agent population for which the geometry wrap property will be returned. May also be an array
of agent populations.
Return
The wrap property as a boolean
See also
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 27/34
setGeometryWrap
setGeometryWrap
function setGeometryWrap(agents,
wrap )
Sets the wrap property for the population area geometry.
Parameters
agents The agent population for which geometry wrap property will be set. May also be an array of agent
populations.
wrap The wrap property for the geometry.
See also
getGeometryWrap
getGeometryUnits
function getGeometryUnits(agents)
Gets the units for the population area geometry.
Parameters
agents The agent population for which the units will be returned. May also be an array of agent
populations.
Return
The units as a string
See also
setGeometryUnits
setGeometryUnits
function setGeometryUnits(agents,
units )
Sets the units for the population area geometry.
Parameters
agents The agent population for which geometry units will be set. May also be an array of agent
populations.
units The units as a string.
See also
getGeometryUnits
getGeometryWidth
function getGeometryWidth(agents)
Gets the width for the population area geometry.
Parameters
agents The agent population for which the width will be returned. May also be an array of agent
populations.
Return
The width of the geometry
See also
setGeometryWidth
setGeometryWidth
function setGeometryWidth(agents,
width )
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 28/34
Sets the width for the population area geometry.
Parameters
agents The agent population for which geometry width will be set. May also be an array of agent
populations.
width The desired width.
See also
getGeometryWidth
getGeometryHeight
function getGeometryHeight(agents)
Gets the height for the population area geometry.
Parameters
agents The agent population for which the height will be returned. May also be an array of agent
populations.
Return
The height of the geometry
See also
setGeometryHeight
setGeometryHeight
function setGeometryHeight(agents,
height )
Sets the height for the population area geometry.
Parameters
agents The agent population for which geometry height will be set. May also be an array of agent
populations.
height The desired height.
See also
getGeometryHeight
getAgentPlacement
function getAgentPlacement(agents)
The placement method for the agent population.
Parameters
agents The agent population for which the placement method will be returned. May also be an array of
agent populations.
Return
The placement method for the agent population. One of Random, Network, Grid or Custom Function.
See also
setAgentPlacement
setAgentPlacement
function setAgentPlacement(agents,
method )
Sets the placement method for the agent population.
Parameters
agents The agent population for which placement method will be set. May also be an array of agent
populations.
method The desired placemennt method. One of Random, Network, Grid or Custom Function.
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 29/34
See also
getAgentPlacement
getAgentPlacementFunction
function getAgentPlacementFunction(agents)
A custom placement function for the agent population.
Parameters
agents The agent population for which the custom placement function will be returned. May also be an
array of agent populations.
Return
The custom placement function for the agent population.
See also
setAgentPlacementFunction
setAgentPlacementFunction
function setAgentPlacementFunction(agents,
func )
Sets the custom placement function for the agent population. The placement method should be set to Custom
Function in order for this function to be used.
Parameters
agents The agent population for which the custom placement function will be set. May also be an array of
agent populations.
func The desired custom placement function.
See also
getAgentPlacementFunction
getAgentNetwork
function getAgentNetwork(agents)
The network method for the agent population.
Parameters
agents The agent population for which the network method will be returned. May also be an array of
agent populations.
Return
The network method for the agent population. One of None or Custom Function.
See also
setAgentNetwork
setAgentNetwork
function setAgentNetwork(agents,
method )
Sets the network method for the agent population.
Parameters
agents The agent population for which network method will be set. May also be an array of agent
populations.
method The desired placemennt method. One of None or Custom Function.
See also
getAgentNetwork
getAgentNetworkFunction
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 30/34
function getAgentNetworkFunction(agents)
A custom network function for the agent population.
Parameters
agents The agent population for which the custom network function will be returned. May also be an array
of agent populations.
Return
The custom network function for the agent population.
See also
setAgentNetworkFunction
setAgentNetworkFunction
function setAgentNetworkFunction(agents,
func )
Sets the custom network function for the agent population. The network method should be set to Custom
Function in order for this function to be used.
Parameters
agents The agent population for which the custom network function will be set. May also be an array of
agent populations.
func The desired custom network function.
See also
getAgentNetworkFunction
FOLDERS
collapseFolder
function collapseFolder(folder)
Collapses a folder or an array of folders.
Parameter
folder Either a single folder primitive or an array of folder primitives.
See also
expandFolder, getCollapsed
expandFolder
function expandFolder(folder)
Expands a folder or an array of folders.
Parameter
folder Either a single folder primitive or an array of folder primitives.
See also
collapseFolder, getCollapsed
getCollapsed
function getCollapsed(folder)
Returns whether or not a given folder is collapsed.
Parameter
folder The folder for which the collapsed state is requested.
Return
True is the folder is collapsed, false if it is expanded.
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 31/34
See also
collapseFolder, expandFolder
getParent
function getParent(primitive)
Gets the parent folder for a primitive.
Parameters
primitive The primitive for which the parent folder will be returned. May also be an array of primitives.
Return
The parent folder. Returns null if the primitive is not in a folder.
See also
setParent
setParent
function setParent(primitive,
parent,
perserveLoc)
Sets the parent folder for a primitive.
Parameters
primitive The primitive for which the parent folder will be set. May also be an array of primitives in which
case they will all be set to the same parent.
parent The parent folder primitive. Use null to remove the primitive from all folders.
See also
getParent
getChildren
function getChildren(folder,
recursive)
Returns the children of a folder.
Parameters
folder The folder for which the children will be returned.
recursive Optional. Whether the children of inner folders will be returned. Defaults to true.
Return
The children primitves of the folder.
getFolderType
function getFolderType(folder)
Gets the type of a folder.
Parameters
folder The folder for which the type is requested. May also be an array of folders.
Return
The type mode as a string. May be None or Agent.
See also
setFolderType
setFolderType
function setFolderType(folder,
type )
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 32/34
Sets the type of a folder.
Parameters
folder The folder for which the type will be set. May also be an array of folders.
type The type mode as a string. May be None or Agent.
See also
getFolderType
getFolderAgentParent
function getFolderAgentParent(folder)
Gets the agent parent of a folder.
Parameters
folder The folder for which the agent parent is requested. May also be an array of folders.
Return
The agent parent as a string.
See also
setFolderAgentParent
setFolderAgentParent
function setFolderAgentParent(folder,
agentParent)
Sets the agent parent of a folder.
Parameters
folder The folder for which the type will be set. May also be an array of folders.
agentParent The agent parent as a string.
See also
getFolderAgentParent
getFolderSolver
function getFolderSolver(folder)
Gets the solver configuation for a folder. The configuration is an object with the properties
enabled true is the folder should have its own solver
algorithm the solution algorithm. Current allowed values are RK1 for Eulers method and RK4 for a
fourth order Runge-Kutta method
timeStep the time step for the folders solver
Parameters
folder The folder for which the solver is requested. May also be an array of folders.
Return
The solver object
See also
setFolderSolver
setFolderSolver
function setFolderSolver(folder,
solver )
Sets the solver object for a folder
Parameters
folder The folder for which the solver will be set. May also be an array of folders.
solver The solver object
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 33/34
See also
getFolderSolver
UTILITY FUNCTIONS
excludeType
function excludeType(array,
type )
Removes a specific type of primitive from an array of primitives.
Parameter
array An array of primitives.
type The type of primitives to remove.
Return
A duplicate of the input array without any primitives of the specified type.
primitiveIndex
function primitiveIndex(array,
primitive)
Locates the index of a specific primitive in an array of primitives.
Parameter
array An array of primitives.
primitive The specific primitive to find.
Return
The index of the primitive in the array. Returns -1 if the primitive is not found.
uniquePrimitives
function uniquePrimitives(primitives)
Returns the passed array with duplicated primitives removed
Parameter
primitives An array of primitives.
Return
An array of primitives with any duplicated elements removed.
setGlobal
Sets the value of a global variable. This can allow communication between buttons or the storing of some state.
Parameter
name The name of the global variable.
value The value of the global variable.
See also
getGlobal
getGlobal
function getGlobal(name)
Gets the value of a global variable. This can allow communication between buttons or the storing of some state.
Parameter
name The name of the global variable for which to get the value.
Return
4/9/2014 Insight Maker API
https://insightmaker.com/sites/default/files/API/files/API-js.html 34/34
The value of the global variable specified by name.
Example
setGlobal("Example Var 1", 42);
setGlobal("Example Var 2", "test");
var z = getGlobal("Example Var 1"); // z is now set to 42
var y = getGlobal("Example Var 2"); // y is now set to "test"
See also
setGlobal
INSIGHT MAKER INTERFACE
topBarShown
function topBarShown()
Determines whether or not the Insight Maker top toolbar (which contains the Run Simulation button and other tools)
is currently shown.
Return
True if the top toolbar is shown, false otherwise.
See also
toggleTopBar
toggleTopBar
function toggleTopBar()
Toggles the visibility of the top toolbar. If it is currently shown, it is hidden. If it is currently hidden, it is shown.
See also
topBarShown
sideBarShown
function sideBarShown()
Determines whether or not the Insight Maker side panel (which contains parameter sliders and information about the
selected primitive) is currently shown.
Return
True if the side panel is shown, false otherwise.
See also
toggleSideBar
toggleSideBar
function toggleSideBar()
Toggles the visibility of the side panel. If it is currently shown, it is hidden. If it is currently hidden, it is shown.
See also
sideBarShown
updateSideBar
function updateSideBar()
Refreshes the values in the side panel to reflect any changes in the model.
Generated by Natural Docs