Setting layers of texts and dimensions
Posted: Sun Mar 14, 2021 9:23 pm
Hello all,
I'm writing a script for changing layers of all texts and dimensions simultaneously:
Texts should result to be in layer called "ret." and dimensions in layer "dim.". But it's not working like this. It seems it is changing all entities to layer "dim". I guess something is not working as I want in the loop.
Any help will be very welcomed. Best regards!
David
I'm writing a script for changing layers of all texts and dimensions simultaneously:
Code: Select all
var di = this.getDocumentInterface();
var document = this.getDocument();
var op = new RModifyObjectsOperation();
var entitiesIds = document.queryAllEntities(false, false);
for (var i=0; i<entitiesIds.length; i++) {
entityId = entitiesIds[i];
entity = document.queryEntity(entityId);
if (isDimensionEntity(entity)) {
entity.setLayerName("dim.");
entity.update();
op.addObject(entity)
}
else if (isTextEntity(entity)) {
entity.setLayerName("ret.");
entity.update();
op.addObject(entity)
}
} // looping ends
di.applyOperation(op);
Any help will be very welcomed. Best regards!
David