Block: Model

A Model block for configuring a Grasshopper model.

Overview

A Model block is used for configuring a Grasshopper model. Typically, models are used to generate geometry that is displayed in a Viewer block, but this is not a requirement. Model can also be used to perform other types of computation.

This block is not visible in the user interface and should therefore not be included in the areas of the frame layout.

In order to get the model inputs, the model needs to subscribe to some other block, such as a ControlPanel or a DataStore. When all the inputs are defined, the model executes.

When subscribing a model to some other block, there are to “actions” that can be performed: set or update.

  • set: (default) Sets all the inputs in the model. If the model has inputs that are not provided by the source, then those model inputs are set to undefined. In such a case, the model will not execute due to the missing input values.
  • update: Sets only the provided inputs in the model. If the model has inputs that are provided by the source, then the values for the additional model inputs are left unchanged. In such a case, if the additional inputs already have values, the model will execute.

Example

Below is an example configuration.

kind: Solution
version: v0
router:
  kind: Router
  routes:
    - frame: home-frame
frames:
  home-frame:
    kind: Frame
    contents:
      my-control-panel:
        kind: ControlPanel
        controls:
          height:
            kind: NumberInput
            label: Height
      my-model:
        kind: Model
        modelFile: my-grasshopper-model.gh
        subscribe:
          - kind: ControlPanel
            frame: home-frame
            source: my-control-panel
      my-basic-viewer:
        kind: Viewer
        subscribe:
          - kind: Model
            frame: home-frame
            source: my-model

ModelConfig

The Model controls a parametric model

Name Type Required Description
kind "Model" Yes
modelFile string Yes A relative path to a valid model file, for Grasshopper models use binary format files (.gh).
The file name can only contain lowercase letters, numbers, and dashes
subscribe List<ModelSubscribe> No A list of objects for subscribing the Model block to other blocks.
triggerSolveOn List<string> No The model solve will only trigger when these specified inputs change

ModelSubscribe

ModelControlPanelSubscribe

An object for configuring a subscription from a Model block to a ControlPanel block. The subscription allows the inputs of a Grasshopper model to be set based on the name-value pairs in the control panel.

Name Type Required Description
kind "ControlPanel" Yes A constant, ControlPanel.
frame string Yes A string specifying the name of the frame in which the ControlPanel is located.
source string Yes A string specifying the name of the ControlPanel.
select "submitted" | "initial" No A constant specifying when the data from the control panel should be used to set the model inputs. Valid options are initial and submitted. The default is both initial and submitted. - initial: The model inputs are only set when the control panel is initialized. - submitted: The model inputs are only set when the control panel is submitted by a user action.
action "set" | "update" No A constant specifying the type of action to perform. Possible values are set and update. - set: (default) Sets all the inputs in the model. Model inputs for which no value is provided will be set to undefined. - update: Sets only the provided inputs in the model. Model inputs for which no value is provided will retain their previous values.

ModelDataStoreSubscribe

An object for configuring a subscription from a Model block to a DataStore block. The subscription allows the inputs of a Grasshopper model to be set based on the name-value pairs in the data store.

Name Type Required Description
kind "DataStore" Yes A constant, DataStore.
frame string Yes A string specifying the name of the frame in which the DataStore is located.
source string Yes A string specifying the name of the DataStore.
action "set" | "update" No A constant specifying the type of action to perform. Possible values are set and update. - set: (default) Sets all the inputs in the model. Model inputs for which no value is provided will be set to undefined. - update: Sets only the provided inputs in the model. Model inputs for which no value is provided will retain their previous values.

ModelPopupFormSubscribe

An object for configuring a subscription from a Model block to a Popup block. The subscription allows the inputs of a Grasshopper model to be set based on the name-value pairs in the popup form.

Name Type Required Description
kind "PopupForm" Yes A constant, PopupForm.
frame string Yes A string specifying the name of the frame in which the PopupForm is located.
source string Yes A string specifying the name of the PopupForm.
select "submitted" | "initial" No A constant specifying when the data from the control panel should be used to set the model inputs. Valid options are initial and submitted. The default is both initial and submitted. - initial: The model inputs are only set when the control panel is initialized. - submitted: The model inputs are only set when the control panel is submitted by a user action.
action "set" | "update" No A constant specifying the type of action to perform. Possible values are set and update. - set: (default) Sets all the inputs in the model. Model inputs for which no value is provided will be set to undefined. - update: Sets only the provided inputs in the model. Model inputs for which no value is provided will retain their previous values.

ModelEntityDataStoreSubscribeForInput

An object for configuring a subscription from a Model block to a EntityDataStore block. The subscription allows a single input in a Grasshopper model to receive a list of entities from an entity data store.

Name Type Required Description
kind "EntityDataStore" Yes A constant, EntityDataStore.
frame string Yes A string specifying the name of the frame in which the EntityDataStore is located.
source string Yes A string specifying the name of the EntityDataStore.
setInput string Yes A string specifying the name of Packhunt Data Input component in the Grasshopper model to receive the list of entities.
filterEntities List<string> No A list of strings specifying names of properties for which data will be sent from the entity data store to the Grasshopper model. Entities that have ’null’ values for any of the listed properties will be discarded.
action "set" | "update" No A constant specifying the type of action to perform. Possible values are set and update. - set: (default) Sets all the inputs in the model. Model inputs for which no value is provided will be set to undefined. - update: Sets only the provided inputs in the model. Model inputs for which no value is provided will retain their previous values.

ModelEntityDataStoreSubscribe

An object for configuring a subscription from a Model block to a EntityDataStore block. The subscription allows the inputs of a Grasshopper model to be set based on the name-value pairs in the selected entity in the entity data store.

Name Type Required Description
kind "EntityDataStore" Yes A constant, EntityDataStore.
frame string Yes A string specifying the name of the frame in which the EntityDataStore is located.
source string Yes A string specifying the name of the EntityDataStore.
action "set" | "update" No A constant specifying the type of action to perform. Possible values are set and update. - set: (default) Sets all the inputs in the model. Model inputs for which no value is provided will be set to undefined. - update: Sets only the provided inputs in the model. Model inputs for which no value is provided will retain their previous values.

ModelMapSubscribe

An object for configuring a subscription from a Model block to a Map block. The subscription allows a single input in a Grasshopper model to receive a JSON object containing the longitude and latitude of the selected point in the map.

Name Type Required Description
kind "Map" Yes A constant, Map.
frame string Yes A string specifying the name of the frame in which the Map is located.
source string Yes A string specifying the name of the Map.
setInputFromMarkers string Yes A string specifying the name of the Packhunt Data Input component that will receive the data from the map.

ModelButtonSubscribe

An object for configuring a subscription from a Model block to a Button block. The subscription allows a model execution to be triggered when the button is clicked.

Name Type Required Description
kind "Button" | "DownloadButton" Yes A constant, Button.
frame string Yes A string specifying the name of the frame in which the Button is located.
source string Yes A string specifying the name of the Button.
action "set" | "update" No A constant specifying the type of action to perform. Possible values are set and update. - set: (default) Sets all the inputs in the model. Model inputs for which no value is provided will be set to undefined. - update: Sets only the provided inputs in the model. Model inputs for which no value is provided will retain their previous values.
setInput string Yes A string specifying the name of a ‘dummy’ Packhunt Data Input component in the Grasshopper model. This input is only used for triggering the model execution and does not need to be connected to any downstream components.