I've found the root of the problem.
In maya/scripts/others there is a mel script called "removeRenderLayerAdjustmentAndUnlock.mel". In this file is the line (line 25) that says:
setAttr -lock 0 $attr;
This line fails if the $attr is referenced (in my case, my referenced camera). Because, as previously stated, all referenced attributes are automatically locked. The error message I get comes from the setAttr command.
The work around is to make a copy of this script and put it in your local scripts directory, and add a check to not try to unlock an already unlocked attribute. Like so:
// skip if the attribute is already unlocked,
// gets around this type of error:
// Error: The attribute 'CMcamera:my\_cameraShape.renderable' was locked
// in a referenced file, and cannot be unlocked.
if (`getAttr -l $attr` != 0) {
setAttr -lock 0 $attr;
}
This won't have much of a side effect since your attribute is already unlocked, so why try to unlock it again?
We also found another way to get around this problem, which I saw mentioned in another post somewhere, and that is to import the camera into your main scene:
file -ir "//project_dir/maya/scenes/cameras/my_camera_M.ma";
This also works (because now the camera is not referenced).
That's it. I'll be sending a bug report to Maya on this...
Shalar