Distinguish unique sessions in Rhino

Hi All,

I’m working on a plugin to collect analytics on Rhino and user interactions with it. What I’m trying to do is to come up with a way to assign a unique GUID to new sessions that the user starts. From my research, Rhino Common doesn’t seem to have a method or ID for each new Rhino document.
I would appreciate if anyone had a similar experience and direct me to the right direction

Hi @ashkan.rdn,

How about this?

public class TestProcessId : Command
  public override string EnglishName => "TestProcessId";

  protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    var threadId = GetWindowThreadProcessId(RhinoApp.MainWindowHandle(), out var processId);
    RhinoApp.WriteLine("Process ID: {0}", processId);
    return Result.Success;

  [DllImport("user32.dll", SetLastError = true)]
  private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);

Windows-only, btw.

– Dale

1 Like

If you just need a unique id per session, create a new Guid and use that when your code first loads

1 Like

Thanks for the response,
What name space GetWindowThreadProcessId is from?

You can do this in .NET with the System.Process class

1 Like