Does an external image link get embedded in the Shapediver file?

Ive linked an external link as a texture in my model in Grasshopper (https://raw.githubusercontent.com/matsnielsen/myfiles/master/flexi-teek-texture.jpg) but when I update the link in Github with a new image-file it doesn’t update in the Shapediver model. When I go directly to the link in my browser it has updated (the two lines are grey, they used to be black). Does Shapediver embed the image-textures in the model when uploaded, or do they get downloaded from the link when viewed in the browser. I don’t see that the images have been downloaded or referenced in Chrome console either. Any help greatly appreciated.

ShapeDiver’s caching system stores all processed solutions to speed up the computation time as explained here. If the link hasn’t changed, the original cached texture is used. You need to add a query string at the end of the link, for example a timestamp:

https://raw.githubusercontent.com/matsnielsen/myfiles/master/flexi-teek-texture.jpg?time=TIMESTAMP

The caching system then takes it as a different URL and updates the image on the server side. I hope this helps.

Thank you for the reply. I see! So that means that if i have no way of actually adding a timestamp to the URL in Github then that solution wont work? Or do you mean that i need to add the timestamp to the URL in Grasshopper? What im basically looking for is how to store image textures externally so that i can make changes to textures without having to upload a new Grasshopper-file to Shapediver.

You can always use the same URL, even if you replace the file. You can just add the timestamp (or whatever random query parameter you want) when you update the parameter using the API.

let textureURL = 'https://raw.githubusercontent.com/matsnielsen/myfiles/master/flexi-teek-texture.jpg';
api.parameter.updateAsync({name: "Texture", value: textureURL + "?time=" + Date.now().toString()});

With that call, the ShapeDiver servers will always download the texture image before updating the model, instead of looking for it in the cache.

1 Like

Please excuse me, but I’m not that advanced when it comes to API and stuff. Do you know if I can do something directly to the URL I set in Grasshopper that will solve this? Like does it help if I add the timestamp in the URL there, or should I add the timestamp to the URL in my FTP server / Github? Again sorry, I’m not that advanced.

You can get a timestamp in grasshopper too with a script. Try this:

timestamp.gh (18.9 KB)

Thank you so much for the reply. Will try this, and post if it works. :slight_smile:

I tried this C# Script and its not working. The problem is, that the script doesn’t refresh the timestamp when reloading the model. It just takes the time and date when the model was uploaded. So, is there any way to trigger the timestamp in GH itself or do I have to trigger a new timestamp via API?

Yes, that was my bad. This solution will not work because of the caching system. There is no way around generating the timestamp outside of the Grasshopper definition, directly in the web application.