Worksession.ModelPathFromSerialNumber() takes ages to run

Hi,

I have a bunch of 3d models that are referenced in a worksession. My goal is to know the reference file path for each referenced object.
All the models and worksession are stored on a remote storage.

Here is my code:

			var rc = RhinoGet.GetMultipleObjects("Select objects", false, ObjectType.AnyObject, out ObjRef[] objRefs);
			if (rc != Result.Success)
				return rc;

			var serialNumbers = new List<uint>();

			foreach (var objRef in objRefs)
			{
				var obj = objRef.Object();

				if (obj == null) continue;				
				if (obj.IsReference == false) continue;

				serialNumbers.Add(obj.ReferenceModelSerialNumber);
			}

			var serialNumbersDistinct = serialNumbers.Distinct().ToList();

			foreach (var number in serialNumbersDistinct)
			{
				RhinoApp.WriteLine(number.ToString());
				var path = doc.Worksession.ModelPathFromSerialNumber(number);
				RhinoApp.WriteLine(path.ToString());
			}

			return Result.Success;

The call to the doc.Worksession.ModelPathFromSerialNumber is taking almost 2 minutes per serial number and I don’t understand why: the path of each referenced file is stored in the worksession so it shouldn’t take that long to translate the serial number into a model path.
Any advice on this?

System Info:

Rhino 8 SR17 2025-2-25 (Rhino 8, 8.17.25056.13001, Git hash:master @ 8d674f13b6b22b7c0498dd9ff031d36e49dcd349)
License type: Commercial, build 2025-02-25
License details: LAN Zoo Network Node

Windows 11 (10.0.26100 SR0.0) or greater (Physical RAM: 63GB)
.NET Framework 4.8.9290.0

Computer platform: DESKTOP 

Standard graphics configuration.
  Primary display and OpenGL: NVIDIA RTX A4000 (NVidia) Memory: 16GB, Driver date: 11-13-2024 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 553.35
    > Accelerated graphics device with 4 adapter port(s)
        - Secondary monitor attached to adapter port #0
        - Windows Main Display attached to adapter port #1

OpenGL Settings
  Safe mode: Off
  Use accelerated hardware modes: On
  GPU Tessellation is: On
  Redraw scene when viewports are exposed: On
  Graphics level being used: OpenGL 4.6 (primary GPU's maximum)
  
  Anti-alias mode: 4x
  Mip Map Filtering: Linear
  Anisotropic Filtering Mode: High
  
  Vendor Name: NVIDIA Corporation
  Render version: 4.6
  Shading Language: 4.60 NVIDIA
  Driver Date: 11-13-2024
  Driver Version: 31.0.15.5335
  Maximum Texture size: 32768 x 32768
  Z-Buffer depth: 24 bits
  Maximum Viewport size: 32768 x 32768
  Total Video Memory: 16376 MB

Hi @jeffoulet,

The methods does more than what it’s name describes. I believe the function also sets the file’s internal checksum if not set. We use this to determine of the file has been change or is the active file. Computing a checksum requires opening and read the file.

– Dale

Hi @Dale, thanks for your input.
The fact that the method needs to open the reference files could indeed explain why it takes so long.

Do you see any workaround?

With what is available in RhinoCommon, no.

I would think it might be slow the first time you query a reference file. Quicker after that.

– Dale