Whilst i appreciate the maya API can be a bit daunting, you must start to appreciate that you are actually going to have to start reading the documentation to be able to achieve anything in the API. As joojaa has said, you need to cross reference the documentation with what you see in the hypergraph. If you do that, the Maya API becomes a hell of a lot easier.
So i'll start by repeating myself, but all of the required information you need is to be found in the docs for MFnSet, and the node+attr reference for shadingEngine.. Please spend some time reading that documentation - for it contains all of the answers you seek.....
QUOTE
Meanwhile... could anybody provide a small and concrete code sniplet with this simple operations, pls?
What you are asking for is not often going to happen. Maya is huge, and you'll very quickly find that very few people - if any at all - will have ever done what you are attempting. So source examples - barring extremely common cases - are very rare to come by.
I will be nice to you just this once, but please understand that this is not a code example i've have lying around somewhere. It is a piece of code knocked up in the last couple of minutes after having read the documentation.
CODE
MFnMesh fnMesh;
MFnSet fnSet;
MFnTransform fnTransform;
MObject oParent = fnTransform.create();
MObject oMesh = fnMesh.create( /* stuff */, oParent );
MObject oSet = fnSet.create("shadingEngine");
fnSet.addMember(oMesh);
bool toggle=false;
// or add the face seperately....
MItMeshPolygon iter(oMesh);
for(;!iter.isDone();iter.next())
{
if(toggle)
{
fnSet.addMember(oMesh,iter.currentItem());
}
toggle = !toggle;
}
MFnPhong fnPhong;
MObject oPhong = fnPhong.create();
MPlug ss = fnSet.findPlug("ss");
MPlug oc = fnPhong.findPlug("outColor");
MDgModifier mod;
mod.connect(oc,ss);
mod.doIt();