Google sheet read with gh

Thanks for the suggestions. I downloaded Everything and searched for it. It found a lot instances of the file and 3 of those in my libraries folder.

It appears that it was the old Leafcutter plugin (which I think doesn’t work any longer anyways) and it had a version of the Newtonsoft.Json.dll file from 2014 :sweat_smile:

I deleted it and now both the version by @AndersDeleuran works fine even in Rhino 7 now.

@archimax I am also trying with your plugin, but you haven’t verified your app yet :wink: This is something you need to do now if you want other’s than yourself authorise your app.

ps: if I accept the warning then it does work fine even with Bookworm

That is genuinely hilarious, full circle baby! What a lesson in dependency hell indeed :laughing:

How come? Were you involved in that?

Just noticed as well that TT Toolbox is by Thornton Tomasetti, who also just joined forces with Shapediver, which is what I am using this in conjunction with.

It truly is a rather small circle…

@archimax I also noticed you don’t have any icons yet. Maybe I can help you with that. I am originally a graphic designer.

Also with Bookworm I still have the same issue where responses are cached. That means if I update something in the sheet I will never see the new data unless I change the range of fields to get. Of course there is nothing online to find out why this is happening and good luck getting any response from Google :confused: My stupid little hack still works fine, but I just don’t get it…

It’s probably this part that is missing in the script:

Like was suggested before it is probably region-specific and some regions might not have full caching enabled (yet). I am in Zurich, Switzerland with the huge Google Campus a mere 2 Kilometers from here, where they develop a lot of that stuff.

Ah no no, was just referring to this:

It would be great actually!

I believe you can’t easily get instant updates because Grasshopper doesn’t update components until any connected parameters are expired. That’s why ReadCellRange component runs only if some inputs are updated.
I’m not familiar with that little pink-box-component in stupid hack but probably it recomputes itself constantly expiring all the components down the wire. That also can be done if you hook up a timer to one of the components


read_test_timer.gh (12.4 KB)

I had to add another “stupid little hack” to prevent unnecessary updates down the pipe if nothing changed in the spreadsheet. The best way to do live updates is to make the spreadsheet notify the component if it was updated. That should be possible but I don’t know how yet :slight_smile:

No, that is not what I mean. What is happening is that I update something in the Google Sheet, I press recompute in Grasshopper and the data coming out of bookworm is still the same as before, since Google is caching the response. No matter how many times I press recompute it will not show the new data. Only if I change the range I want to get does it actually look at the current data of the Google Sheet and show me the new data. If I go back to the old range it will show me again the old data from Google Sheets.

No. It’s a random number generator (from the Heteroptera plugin), that just creates a random number on each recompute. So basically I am getting a new range of fields on every recompute. Since no matter how many rows you request, you only get back the rows where data exists, it’s my trick to always get the up-to-date data.

It seems like this is a region-specific thing, since people in other countries are not reporting that behaviour. But it seems like there is a way to tell Google to always request the new data if you look at that link on Stackoverflow.

Take a look at the video here: Google sheet read with gh - #56 by seltzdesign It’s exactly the same behaviour with bookworm. Notice how when I go back to the range A1:B10 it shows again the cached response from before (with foo and bar in the first row).

I had to explain my situation =) In rhino 6 component works as expected, it updates the data if I change something in google sheets. But after installation rhino 7 it also work, but it’s loads some cached data (as you described in previous posts), even i change the data in google sheets and recompute the definition in grasshopper. Same situation in both Rhino 7 and 6.
But when i uninstall Rhino 7 - it’s working again as expected in Rhino 6. I’ve tried your solution (stupid hack) =) , but it didn’t help much. There is some issue or conflict between Rhino 7 and 6, but i’m so stupid to understand what’s the matter =)

Sounds like it is a separate issue almost. For me the behaviour is identical in Rhino 6 and Rhino 7. It always caches the responses and needs a new range to update. Since I don’t think any caching is done locally, it must be Google doing the caching. The big question is why they never clear their cache or what is missing in the plugin to force them to do it.

I did it twice (uninstall rhino 7) on two separate computers, and it works as before (without cache issue) :grimacing:

Okay. But I only started using Rhino 7 a few days ago and the issue was there before.

getting the error
Runtime error (ArgumentTypeException): expected Initializer, got Initializer

Traceback:
line 49, in makeSheetsService, “”
line 56, in script

for both the read and write component. this is happening in both rhino 6 and 7

@archimax I am coming back to this as I still have the same problem and the “stupid hack” I made can still load a cached result from previously, which is a big problem.

I made another video of a test Google Sheet with your file next to it and you can see the behaviour. I can also invite you to the Google Sheet and then you can try it for yourself and see if the behaviour is different. Or you can share one with me and then I can see if it makes a difference (I’ll send you a pm).

For now it’s like this:

ps: Did you check this: javascript - Google Scripts seems to be Caching Cell Values - Any way to avoid? - Stack Overflow He is confirming that caching is taking place and how to work around it.

Year, this video is unsettling for sure :slight_smile:

Could you please make a quick test of writing something with bookworm to google sheet before reading it again? If this helps I can add a write transaction before every read as an option.

I think it might be a solution. I read somewhere where they circumvented the cache by always writing a time stamp or random number to A1. Not very elegant, but maybe it works.

But there has to be a proper way and I think its with the flush() command, but I can’t find anywhere a proper instruction on it. :thinking:

Hi Max.

No, it does not help. Even if I write a timestamp to the sheet at the same time, it always reads a cached response.


read_write_test_timer.gh (11.7 KB)

Hello Armin,

Thanks for explaining the whole process step-by-step, I was able to follow them until the end even though I’ve never used Google Console before and I don’t really code. However, I have one issue that does not allow me to complete the whole setup.

As you can see on the image above, I get an error once I recompute the Grasshopper definition (I already downloaded the client_secret.json and placed it on the GoogleSheets folder, along with the Dependencies; and I also copied my own Google Sheets ID). It seems as if I need to authorize something on the Google Console, but I have no idea what or where. Could you help me out with this?

Best regards,

Hello. The Bookworm plugin is elegant and really helpful. Thanks for creating it. Is there some progress on that caching issue? I am experiencing the exact same behavior as shown on the video above. Thanks.

EDIT: Getting fresh data works just fine when using “Read Cell” instead of “Read Cell Value” component. It also takes way more time to load (around 400ms in my case). I assume that it’s getting always a fresh data instead of reading cached data? Anyway, I can live with that I guess… :slight_smile: Just a bit more components to deconstruct the cell to get the value…

developers google. com / sheets / api + quickstart / + dotnet takes me to javascript (JavaScript Quickstart  |  Sheets API  |  Google Developers)

Does not exist anymore? Any ideas why? I can´t follow this first steps :confused:

Hello @gokulgupta1997 . Any updates on this error? I would be pleased if you could share some hint. Thanks!