Hi,
There is any example to change the current layer color by script code?
I have seen the module RLayer --> setColor but i don't know how his use is.
Thanks
[SOLVED] RLayer setColor
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.
[SOLVED] RLayer setColor
Last edited by sinase on Thu Mar 18, 2021 6:20 pm, edited 1 time in total.
Re: RLayer setColor
You can find an example script that changes the color of a layer at:
viewtopic.php?f=32&t=6008&p=22580#p22580
The ID of the current layer can be queried as:
viewtopic.php?f=32&t=6008&p=22580#p22580
The ID of the current layer can be queried as:
Code: Select all
var id = document.getCurrentLayerId();
Re: RLayer setColor
Thank you Andrew,
var di = this.getDocumentInterface();
var document = this.getDocument();
var op = new RModifyObjectsOperation();
var id = document.getCurrentLayerId();
var layer = document.queryLayer(id);
layer.setColor(new RColor("#ff0000"));
op.addObject(layer);
di.applyOperation(op);
This code works for my application.
Regards.
var di = this.getDocumentInterface();
var document = this.getDocument();
var op = new RModifyObjectsOperation();
var id = document.getCurrentLayerId();
var layer = document.queryLayer(id);
layer.setColor(new RColor("#ff0000"));
op.addObject(layer);
di.applyOperation(op);
This code works for my application.
Regards.