Env variables of grasshopper - Shapediver models

I wonder if there is a possibility to extract grasshopper environment variables?
It might be a GH general topic but I would like to code in my definition to extract if the GH model runs on my local machine OR at the servers of Shapediver. I would need somth very basic as DEV and PROD.

My use case:

  • Feed in JSON object from the code during development
  • Or Get the JSON from a front end or cloud storage file once in production

@Balazs_Kisfali you could do that by defining some environment variable in your local development environment, which won’t exist when your model runs on ShapeDiver. Then use a C# scripted component to check the existence and/or value of that variable.

1 Like

Hi @snabela thanks, actually I wanted something without script components, as those are subject to overview by your team once the model is uploaded to SD. Since I am frequently pushing new GH definition to SD, it would be cumbersome to wait for those reviews. …but this would solve the problem once the definition is “stabilised”, …which will be sooner or later :wink:

@Balazs_Kisfali every script that has been confirmed by us once does not need to be reviewed again, i.e. not really a problem, as long as you keep that code in a separate script.

Hi @snabela I’m sorry, I missed your comment earlier, …that sounds good. When you say “separate script” do you mean a Python component for instance in GH?

Yes, any script component is treated individually (Python, C# or VB). Which means that if you don’t modify the script in any way, it will go through the validation process only once, and bypass the validation in the following uploads. This is also true if you just reuse the component in a completely different definition.