To know whether a camera is one-node or two-node is not completely obvious since there is no corresponding layer attribute.
But given that you want to put an expression in the poi property, you have to use canSetExpression and this sort of auto solves it.
If you have never scripted before, here's a sample code to build upon:
function campoi(){
var comp = app.project.activeItem;
if (!(comp instanceof CompItem)) return;
var layers = comp.selectedLayers;
var n, N=layers.length;
var null3D;
var num2NodesCams = 0;
for (n=0; n<N; n++){
if (layers instanceof CameraLayer && layers.transform.pointOfInterest.canSetExpression){
// add a null, make it 3D
null3D = comp.layers.addNull();
null3D.threeDLayer = true;
null3D.name = layers.name + "_Target";
// add a poi expression
layers.transform.pointOfInterest.expression = "thisComp.layer(\""+null3D.name+"\").transform.position";
++num2NodesCams;
};
};
if (num2NodesCams===0){
alert("Please select a two-node camera");
};
return;
};
campoi();
Xavier