Importing Layer Information

Hi everyone
I want to import the layer information into the script. I did something like attached. But I need the number of objects in the layer. How can I achieve this?

Does it have to be a script or would you be able to use a plugin such as Elefront?

I’m a novice. I’m open to trying any path to a solution. I use Elefront a little.

elefront_number_of_objects_on_layer.gh (15.8 KB)

1 Like

That’s great. Thank you so much.

1 Like

Continuing with Python, you could maybe do something like this:

import Rhino
import scriptcontext as sc
import System.Guid, System.Drawing.Color

a = []

def SelLayer():
    sc.doc = Rhino.RhinoDoc.ActiveDoc
    layernames = sc.doc.Layers
    for i in layernames:
        rhobjs = sc.doc.Objects.FindByLayer(i)
        a.append(len(rhobjs))
    sc.doc = ghdoc

SelLayer()

This is based on the RhinoCommon example given here:
(Layer.Name Property)

3 Likes