Enable user to save state

Is there a way with Shapediver to enable a client to save a design they have part worked on and come back to it later to complete and possibly purchase?

1 Like

Since you are mentioning clients saving and coming back later to finish their purchase, I will assume here that you have a user management system with all the relevant databases available. Therefore, your question amounts to saving the set of parameters that your users have worked on before they leave your configurator, and loading them again later when they come back.

The parameters interface of the API lets you read the current state of parameters and update them at will, therefore what you are trying to achieve is relatively easy. In order to save a configuration produced by a client of yours, just save the JSON response of the following API function:

let state = api.parameters.get().data;

When the user comes back, you can call the following function after the viewer is loaded:

let loadState = function(state) {
    let updateObject = [];
    for (let i=0; i<state.length; i++){
        updateObject.push({id: state[i].id, value: state[i].value});
    }
    api.parameters.updateAsync(updateObject);
};

We will be using a developer from a few Ezequiel has recommended to implement your API and embed in a website.
As such, the user management system and databases would be held by Shapediver, is this correct?

ShapeDiver does not provide anything besides access to your Grasshopper definitions in a cloud environment, as well as an online 3d viewer to visualize geometry included in those definitions. Everything else will have to be setup by your web developer. If Ezequiel recommended one, then they will be able to advise you on the best route to take.

Hello @mathieu1

Regarding the state of all parameters, I found this discussion and this info in the documentation : https://help.shapediver.com/doc/saved-states#SavedStates-Updatingastate

How can we save and upload a state, contaning all parameters values, from the V3 API?

Should we use : SDV.sessions[‘model-view-session’].parameters
and then create a JSON ?
If yes, Does the input ID’s change on each new shapediver’s file version?

Or is there a other solution?

Thanks

The Saved State feature of ShapeDiver is currently not exposed through APIs, therefore in order to create and manage the state of all parameters in a model, you will indeed have to manage it on the side of your web application.

It is straightforward to implement this feature in your application, because the parameter IDs do not change between versions of a model, as long as you did not delete and replace a parameter in the Grasshopper definition. Therefore the method you describe in your message will work. We have done something similar in the ShapeDiver platform, allowing users to save and load the parameter states in a JSON file (see here).

2 Likes