How can I show / hide layers of a document in a script?
Showing / hiding layers
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Showing / hiding layers
From a QCAD user:
Re: Showing / hiding layers
Showing / hiding a layer is a modification of the document. Like all modifications, this has to happen in an operation, triggering a transaction:
Code: Select all
var operation = new RModifyObjectsOperation();
var layers = document.queryAllLayers();
for (var l = 0; l < layers.length; ++l) {
var layer = document.queryLayer(layers[l]);
if (layer.getName()==="MyLayer") {
// show layer "MyLayer":
layer.setFrozen(false);
} else {
// hide all other layers:
layer.setFrozen(true);
}
operation.addObject(layer);
}
documentInterface.applyOperation(operation);