the tangent flag can mess up a replaced mesh. i guess the engine still uses some data from the old mesh for tangent calculation and there is nothing i can do about it. if this happens this trick should help:

Code:
material mtl_normalmapping
{
// flags = tangent; // don't set the tangent flag here if you use a replaced mesh!
effect = "normalmapping.fx";
}

[...]

you = ent_create("model.mdl", nullvector, 0); // load model with texture uv-set
you.material = mtl_normalmapping;
mtl_normalmapping.tangent = on; // set the tangent flag only for one frame
wait(1);
mtl_normalmapping.tangent = off;

// load the second uv-set after disabling the tangent flag
// the tangents still are in the mesh

tempentity = ent_create("model_lm.mdl", nullvector, 0); // load model with light map uv-set
ent_loadseconduvset(you, tempentity); // generate and assign a new mesh with both uv-sets
ent_remove(tempentity); // tempentity isn't needed anymore





...
and another tip: you don't really have to use ent_exportmesh()/ent_importmesh(). these functions are only meant for the case when ent_loadseconduvset() is too slow (and i need them for the demo) but it usually shouldn't be too slow. before the release of the plugin i used a slow brute force algorithm for a while but i made it much faster for the release.