As a mini project, I thought I would write a function that would allow a user to get a selected set of nodes and add them to the current OR a new layer. I know this can be done visually in the layer manager and its probably overkill in that context, but the code here could be useful if you are creating large object sets and then need to put them on a layer as part of a process in a class.
Feel free to comment and critique it, I have put some notes at the top of the pasted code block. It has some scope for improvement, both in its execution and in its format, but the general idea is sound. (I think!) 
"""
Written by: Malcom Armstrong
Date: 08/05/2018
Description:
This will allow a user to add a set of selected nodes to the current layer (curLayer=True) or a new layer (newLayer=True, newLayerName="SomethingOriginal)"
Usage:
To add selected nodes to new layer: addSelectedToLayer(theObjs, curLayer=False, newLayer=True, newLayerName="myNewLayer")
To add nodes to current layer: addSelectedToLayer(theObjs, curLayer=True, newLayer=False, newLayerName="")
Current limitations:
No check for existing layer name
Only prints warnings
Format could probably be more 'Pythonc'
try ecxept?
clunky way to get the selection count, probably need selection cast to maxPlus.ObjectList() and then append the selection
"""
import os, sys
import MaxPlus as mxp
def addSelectedToLayer(objectsToAdd, curLayer, newLayer, newLayerName):
objectsCountList = [i for i in MaxPlus.SelectionManager.Nodes]
if len(objectsCountList) > 0:
if curLayer and not newLayer :
cur_layer = mxp.LayerManager.GetCurrentLayer()
for node in objectsToAdd:
print "Adding {} to the current layer".format(node.Name)
mxp.Layer.AddToLayer(cur_layer, node)
elif not curLayer and newLayer:
print "Creating a new layer and adding selected nodes to it"
if newLayerName != "defaultLayerName":
print "New layer name {} is set and is valid as the value for the new layer".format(newLayerName)
new_Layer = mxp.LayerManager.CreateLayer(newLayerName)
for node in objectsToAdd:
print "Adding {} to the new layer: {}".format(node.Name, newLayerName)
mxp.Layer.AddToLayer(new_Layer, node)
else:
print "New layer name is required"
elif curLayer and newLayer:
print "Not possible to add nodes to current and new layer"
else:
print "At least one argument (curLayer or newLayer) needs to be passed as True"
else:
print "Nothing is currently selected"
theObjs = mxp.SelectionManager.Nodes
addSelectedToLayer(theObjs, curLayer=False, newLayer=True, newLayerName="myNewLayer")