Well see the problem with your question is as follows it says:
- the mel command is crap AEnewNonNumericMultiAddNewItem. I wish not to use it.
Answer dont use it but take a look at what it ate to see why it craps up. Still use maya script inetface for this its trivially much easier. This is the thing you SHOULD be working on. Its a clear indication thet you have misunderstood a cornerstone on how maya works. You may be experienced but youve stormed past something important.
Unreliable? Well yes its a procedure defined for the AE and off course it will not exist for calling when the function isnt loaded. The reason its not always available is because the procedure not meant for you. This said very easy to force it to load. Just run:
source AEnewNonNumericMulti;
Offcourse your right this is not a very good idea in general, you can accomplish the same thing with (see the file returned by whatIs AEnewNonNumericMulti), so you can in MOST cases condense the entire call to:
getAttr -type your.plug[12]; // where 12 is the index you wish to add
Since you clearly know how to echo maya commands you still need to learn how the environment works. The command accepts attribute ranges with slice notation so if you wanted to add 100 plugs youd go [0:99]. Now this is quite simple to do in api if your NOT interested in UNDO (using maya api calls but written in python to make it easier to verify):
import maya.OpenMaya as om
# presumably you know a better way to fetch the plug
selList = om.MSelectionList()
plug=om.MPlug()
selList.add("plusMinusAverage2.input1D")
selList.getPlug(0, plug)
# eof getting plug
# get the value
nuPlug=plug.elementByLogicalIndex(12)
# and set it
nuPlug.setInt(0)
# obviously you will need about 20+ lines of error checks and
# possibly undo and redo of what you did as well for4 another 50+ lines.
# it also gets complicated if you want to check type and all possible layouts such
# as compounds of arrays of arrays with floats in between. So the code easily gets
# into 600 lines of code if you want to do ALL that the
# getAttr -t attribute.name does. And its still as slow
its just not productive, especially if you want to tackle all possible cases and you often do. Most of the time you actually see API plugs call mel commands here becasue its simpler to manage, debug, troublshoot etc. See the plug has a function that can expand the plug into a name so you can easily do just that.
Answer 2, mel is silightly ineffcient sometimes. Butwhen setting a attrubute maya API is NOT more efficient. It is in fact more productive than the api. Its only if you truly must set 2500-10 000 attribs that it makes sense to do it all in the api. then theres a small gain.
- I must do it this way. And not use MEL
This is a leading question it leads to you having problems. Its not productive to solve problems with the mistakes in thinking you have. See the 90% answer is there to underline the FACT that you are not the only one reading the answer. If i shoot you down now i save somebody else from your mistake. Everyone who ask the question want to use api for XYZ is wrong, atleast untill they can elborate.
The fact is you have no compelling reason to not use mel, or atleast you dont tell me any. Since that would constitute a bad advice wich would lead a lot of users into a trouble in future. Your asking us to tell you how to break a golden rule, it doesnt get done lightly.
So dont shoot the messenger. You are here to learn. About 1% of all API askers react the way you do,, and being nice doesnt help. Ist just a unfortunate fact of not getting the scope of the question right.