What's new

Welcome to the GSA Community!

This is the Official User Community for GE's GeoSpatial Analysis products. By registering with us, you'll be able to discuss, share and private message with other members of our Community.
Registration is currently only allowed with a personalized invitation code, which you might have received previously. If you haven't got one:
please get in touch with your GE contact person or your regional moderator(s): see FAQ.

SignUp Now!

How to use environment variables in expressions

yosuke.takahashi

Member
Confirmed GSA Customer
Joined
Sep 28, 2020
Messages
8
Hello,

We would like to use environment variables in expressions.

1607390767080.png

1607390841168.png

GSA supports environment variables(%SOURCES% in the above example), but they are available only in the path of feature sources, not in expressions.

This is our workaround.

1607391026184.png

We create a csv file, which stores environment variables in it.

1607391066009.png

Add the csv to feature source.

1607391474423.png
Join a business collection to the csv collection. The join expression should always return true.

1607391875650.png

Use csv's path in the expression.

1607391934558.png
The link to the document works.

But I think this is not a good way. Are there any other workarounds?

Regards,
Yosuke
 

Attachments

  • 1607390961714.png
    1607390961714.png
    50.4 KB · Views: 0
  • 1607391575131.png
    1607391575131.png
    31.9 KB · Views: 0

Frank Pistorius

Spatial Eye
Confirmed GSA Customer
Joined
May 26, 2020
Messages
36
Hi Yosuke,

Thanks for sharing, this is indeed a great trick.

It is actually possible to access environment variables directly from the expression language.
This can be done via Environment.Variable() and can be used as follows:
Code:
{
    # Get the project directory from the environment
    var projectDir = Environment.Variable("SEPROJECTDIR");
    
    # Get the Data subdirectory
    var myDataPath = Path.Combine(projectDir, "Data");
    
    # For demo, just return this value
    return myDataPath;
}

See Environment.Variable() for more information on this in the documentation.

Regards,

Frank
 

markvanderhurk

Spatial Eye - Moderator
Staff member
Confirmed GSA Customer
Joined
Sep 28, 2019
Messages
38
Hi Yosuke,

It looks like this is what you are looking for:
1607423153484.png

Using double quotes around the name of the variable (comparable to %variablename% in paths). You can use the built in variables as well as variables you have set yourselves (in your example SOURCES would become Environment.Variable("SOURCES") )

Does this solve your concern?

Best regards, Mark

// it looks like Frank was just a tiny bit earlier in providing an answer :D
 

Attachments

  • 1607423130929.png
    1607423130929.png
    186.5 KB · Views: 1

yosuke.takahashi

Member
Confirmed GSA Customer
Joined
Sep 28, 2020
Messages
8
Hi Frank and Mark,

Oh, I didn't know Environment.Variable()...
It works well! Thank you guys!

Regards,
Yosuke
 
Top