Looping Methods Allowed on Shapediver

Hi everyone,

I have a question about looping using C# scripting in Grasshopper, and more generally, what c# scripting is allowed on Shapediver.
I need to loop through the JSON file to create a series of geometry, but also present the entire collection of geometry. My looping script iterates through the one number slider and then capture the image of each iteration. But it turned out some of the scripting element is not allowed on ShapeDiver. So I was wondering if there is anyway to do the looping, and save all geometry.
images.gh (109.6 KB)

Thanks all!!

Yi Yang

On ShapeDiver, you need to keep an explicit relationship between a set of parameter values and a specific result. You won’t be able to loop and recompute your entire Grasshopper definition directly from inside Grasshopper. The second point is about ‘capturing an image’ of each iteration. I see in your script that you are trying to save images locally, which is not allowed because those images would be stored on the ShapeDiver servers. You should use instead the export component, which can export images from the online viewer.

In the current state, your definition is not compatible with ShapeDiver. If you want to transpose this behaviour online, I would suggest to add a single image export component as an output of the definition, and do the looping using the API after the model is uploaded.

Thanks for the reply!
A followup question would be how feasible is it to automatically loop using the API? Are there any documentation on it?

also, when exporting the images, is it also possible to automate the process of exporting multiple images (maybe through API)?

So sorry to bother you again, but as I used the Make2D and then Squid to allow me to export the images online, the server keeps saying it was taking too long. I changed PPU of Squid to a pretty low value, and tried to simplify the object, but none of them worked. Do you know if there is some way to make the Make2D and Squid more efficient to pass the server time test? Thank you so much!
images2.gh (103.1 KB)

@cyang21 you can automate the process of exporting via the API. Howerver, each ShapeDiverExportDownload component just accepts one file output. So if you want to export 5 files, you will need to have 5 export components in Grasshopper and then loop with the API to get all of their Export Results. The result.href will contain the links that you can store for download, in this example you would need to catch the 5 links generated for the 5 export requests.

Regarding your Make 2D definition, there is several things that you need to fix:

  1. Convert your B-reps into meshes before sending to Make2D and to ShapeDiver as that will run faster. Learn more about it in our blog here.
  2. You can not use Make2D Rhino View component as this requests the view from the Rhino viewport. Instead, you need to create your own view from scratch using Make2D Parallel View or Make2D Perspective View.
  3. You were sending a tree with 13 branches to the Make2D component. This means the component was running 13 times, what takes lots of time to process for this component. Instead, you need to send a list or an item to the component so it creates a single view from the geometry. You just need to send a tree if you are going to create complete different views in each branch.

I have made some changes in your definition and you can check it here (Now the download works in ShapeDiver):
images2.gh (110.0 KB)

Hope this helps.