Clicking "OK" in the Group dialog box using maxscript


Hi, I am pretty new at max-scripting. I have a whole bunch of objects that are arranged in layers and wanting to create a loop that generates Groups for all these different layers. My issue currently is that when I am looping through this process I have to manually hit enter when the Group dialog box appears. Is there an easy way of hitting the “ok” button though maxscript? Thanks

	for i = 0 to layerManager.count - 1 do
		layer = layerManager.getLayer i
		layerName =
		layerNodesArr = #()
		layer.nodes &layerNodesArr
		grp = group layerNodesArr name:layerName 
		if isValidNode grp do layer.addNode grp


This works perfectly! thank you so much for your help!