Points Input
Use the Points Input component of the plugin to let users of your Apps (and models in the future) draw and edit points and polylines in the online viewer. In Grasshopper, the input points and curves are retrieved in the component and can be used to drive the rest of the definition.
Overview
Consider the following simple definition: an input polyline is used as a control polygon to define the boundary of a Voronoi partition. A second input defines the partition's number of cells. In the end, we display the resulting cells using a glTF 2.0 Display component.
After uploading this definition to ShapeDiver, the platform parses the input slider, allowing users of the online model to update the number of cells of the result. But the boundary remains fixed.
In order to expose the control polygon to the online application, one simply needs to add a “Points Input” component to this definition, and connect it to the input curve parameter:
After adding the component, its output is empty, but it is possible to right-click on the component and define a default value; one will then be prompted to draw a series of points or a polyline (depending on the Mode, see below) which will used by default.
After uploading the definition to ShapeDiver and saving the model, open the App to see the new Points Input:
Click on the button to enable the drawing mode. The default points or polyline defined in the component will be displayed in the viewer, with handles allowing to add, remove or edit the points:
Read more in the next section about how to constrain the drawing to other planes or objects in the scene and restrict the allowed number of points.
Download the Grasshopper definition of the example here.
Component options
Mode: Three drawing modes are available.
Points: The component outputs a list of points. In the online viewer, the points will be drawn individually in the viewer (without lines between them).
Open Polyline: The component outputs an open polyline. In the online viewer, the polyline is drawn between the points.
Closed Polyline (default): The component outputs a closed polyline. In the online viewer, the closed polyline is drawn between the points.
Min. point count: The user will be asked to pick at least this number of points.
Max. point count: The user will not be able to pick more than this number of points.
Set plane constraint: This option restricts point selection in the viewer to a specific plane. It defaults to
WorldXY
.Set geometry constraints: This option restricts point selection to specific meshes displayed in the scene. The meshes need to be included in a glTF 2.0 Display component and each need to have a defined
name
attribute. Read more about filtering objects for interactions in this article and in the next section.
Download the Grasshopper definition of a geometry constraints example here.
Default value: Set a series of points or a polyline (depending on the Mode) that will be used as default value for the input. Leave the default value empty if you want users of the App to start drawing points from scratch.