Pointcloud object name to layers

I work with a large number of named pointclouds in a file and would like to transfer each one of them to a new layer named as the object name. I have read some post about similar subjects but nothing really matches. I tried to make a grasshopper definition and with help of the Cockroach plugin it is possible to select (set) pointclouds in grasshopper. Sadly the pointcloud container doesnt transfer the object name to the “Object Details” function so it was no sucsess. My goal is to be able to pick the pointcloud i would like to transfer to avoid setting all object in the file to a specific layer. Has anyone a idea?
/Fredrik

This requires legacy Elefront (package manager install or food4rhino)

I selected the point clouds in this case but could be referenced via Elefront components as well


Re_Change_Cloud_Layers.gh (6.7 KB)

Hello- in case it is helpful, I had python this lurking in my scripts folder -
import rhinoscriptsyntax as rs


def ObjectToNamedLayer():
    
    ids = rs.GetObjects("Select objects to layerize.", preselect=True)
    if not ids: return
    
    for id in ids:
        name = rs.ObjectName(id)
        if not name: continue
        if not rs.IsLayer(name):
            rs.AddLayer(name)
        rs.ObjectLayer(id,name)
        
    
if __name__ == "__main__": ObjectToNamedLayer()

-Pascal

Thanks Pascal!
Worked like a charm! My script folder contains only scripts.from you. Thanks again.
/F

Thank you Japhy!
I acctually had Elefront installed but I didnt try it in this case. I realize this was the only way to do it otherwise I would have ended up with a baked copy in a layer. But I dont understand why its needed to graft the input of the ModifyAttributes?

In this case you could get away with not grafting. What you are looking to end up with is a 1 to 1 relationship with Geometry to Attributes. This comes more into play if you are assigning UserText with multiple values etc. Elefront will throw an error if the things don’t match.