Assign object to layer by Layer Name

I’m trying to assign an object to a Layer by using the layer name, but I’m so far not able to get it done, the best example I can find:

But that uses the layer index. In my case I have just created the layer and given it a name:

for item in items:
    itemObject = importRhinoFile(item)
    itemName = item.replace(".3dm","",1)
    itemName = itemName.replace("Base","",1)
    itemLayer = Rhino.DocObjects.Layer()
    itemLayer.Name = itemName
    sc.doc.Layers.Add(itemName)

I would now like to assign the item with itemName to the layer with the same name. Is this possible?

https://developer.rhino3d.com/api/RhinoScriptSyntax/#object-ObjectLayer
Something like:

import rhinoscriptsyntax as rs
rs.ObjectLayer(itemObject, layer=itemName)
1 Like

Ah yes, that’s in the third API. Could have known since it regards objects that are currently in the workspace. Thanks.