Is .gh file opened?

Hello!

Is it possible to check if a .gh is already opened by another user?

Based on this:

Grasshopper behaves somewhat different than most programs when it comes to files. When you open a file a program typically locks that file, so nobody else can change it. Grasshopper doesn’t.

from old forum

it is not possible?

The idea would be to check if a .gh file is opened already by other user before opening the file, so that multiple instances of the .gh file would not be opened at the same time which could lead to users undoing each others changes in the file when saving.

I tested with a simple script with C# component
try
{
using (Stream stream = new FileStream(filepath, FileMode.Open))
{
A = “File is not in use”;
stream.Close();
B = filepath;
}
}
catch
{
A = “File is in use”;
B = filepath;
}

It works with .3dm file but not with .gh file

We have tried to split the project into multiple .gh files(one .gh file designated to one user), but sometimes it is not enough.
Is there a workaround for this, preferably not using 3rd party plugins?

B r, Kristoffer

If all Grasshopper instances are running on the same computer, you may probe opened files.
But Grasshopper doesn’t lock files so generally no.

1 Like