DirectTextInput format for multiline data?

Hello,

I want to send point data through the Shapeiver Viewer API to fill a parameter input for a model.

For individual points, I’ve done this through sending a string ‘{x, y, z}’, e.g:

    SDV.addListener(SDV.EVENTTYPE.INTERACTION.DRAG_END, async () => {
        session.getParameterByName("upperPoint")[0].value =
            "{" + upperBall.node.boundingBox.boundingSphere.center.toString() + "}"
        await session.customize();
    });

and of course lists of points can be formatted in many ways, e.g. JSON.stringify as shown here.

My question is if there’s some best practice here, for generally sending point or other data to .gh models, or if it’s indeed simply best to accept a direct text input and parse it in grasshopper.

Many thanks,
Max

At the moment, the method you are using (i.e send a single string and parse it in Grasshopper) is a common practice and the way we would recommend to handle your use case.

We are currently working on a new point input data type which will allow to define directly multiple points in a single input, as well as handle the dragging of those points in the viewer without the need to write code. Once this is out, this should simplify some parts of your application’s code. I will get back to you once this new feature can be tested.

1 Like