I'm trying to write a script in order to rename all layers of a file, adding "z ... " at the beginning of their current name, so they'll be all inside a new superlayer called "z".
My script looks like this:
Code: Select all
var di = this.getDocumentInterface();
var document = this.getDocument();
var layerIds = document.queryAllLayers();
var op = new RModifyObjectsOperation();
for (var i=0; i<layerIds.length; i++) {
var layerId = layerIds[i];
var layer = document.queryLayer(layerId);
var prevLayerName = layer.getName();
// void RLayer::setName ( const QString & n )
layer.setName(new ("z ... " + prevLayerName));
op.addObject(layer);
};
di.applyOperation(op);
this.terminate();
I was thinking I need to "update" layers or something similar...?
Thank you! Best regards,
David