Heh, I'm almost your "evil twin brother" - not a programmer, terrible math skills. I'm an artist and used to weird methods to workaround max's... occasional unexpected behavior, maybe that's why maxscript looks normal to me.
Line #1
It defines macroscript so it can be used through Customize to put on toolbar or assign a hotkey for it.
Line #3
selection[1] just tells max "whatever is selected, use first of that" and yes, $ and "selection" can work for one thing, but throw an error for the other. Can't say I fully understand it, but usually can find a way to use it.
Line #4
Editable_mesh doesn't have a way to create shape from edges. Recreating it manually would be too complex for me. Easier approach is to convert to Poly first, but that might be undesirable for Ryawy.
Lines #5 and 6
If no edges selected there is nothing to create a shape from. Also script might crash when trying to do something like that.
Line #7
Creates unique name for new shape using original object's name as prefix. For me it makes sense - allows to figure out what it was made from. Might create a mess after working with few objects named "Box001", "Box002" etc, but I don't know how max file is organized.
Line #8
Creates shape from selected (flagged with 1) edges.
Line #9
I need to do a bunch of stuff with new shape, but when it's created, original poly object is still selected. Getting reference to shape by name since it seems like a proper way to do that without switching selection from poly to shape and then back. That would be slow with interface flickering.
Assigning it to variable because max documentation had suggestion of caching everything when possible and it's more convenient to work with for me.
At least that's what I think it does 😃