C# Get sub-layer objects from external rhino file

Hi all,

I am trying to use c# script to access an external rhino file in my local document folder.
The question is I cannot retrieve the objects if it is located at the sub-layers.

I am mainly using file.Objects.FindByLayer to access the layer.
I saw it is also possible to access by file.AllLayers.FindName(“sub-layer02”, GUID parentId);, but I am having difficulty to find the Guid parentId.

Here is the code:
> string folder = @“C:\Users\Shaun Wu\Documents”;

Rhino.FileIO.File3dm file = null;

if (Directory.Exists(folder))
{
  var files = Directory.GetFiles(folder, "*.3dm");
  file = Rhino.FileIO.File3dm.Read(files[0]);
}

A = file;
B = file.Objects.FindByLayer("Layer01");
C = file.Objects.FindByLayer("Layer02");;
D = file.Objects.FindByLayer("sub-layer02");

//file.AllLayers.FindName("sub-layer02", GUID parentId);

LayerExample.3dm (41.8 KB) example.gh (5.5 KB)

Thanks for the help.
Shaun

Hi

You should use the layer’s FullPath,At the same time, there are empty characters in the layer in your rhino file.

Hi Naruto,

Thanks for your help.
Is it possible to access the sub-layer by its full name, not by layer’s sequence?