Doing layer changes in one operation

Discussion forum for contributors and developers who are using the QCAD ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Post Reply
sarlaa
Active Member
Posts: 47
Joined: Mon Aug 28, 2017 4:39 pm

Doing layer changes in one operation

Post by sarlaa » Wed Jun 27, 2018 11:09 am

Hi,

How can I remove a layer, and set an other one as current layer in the same operation.

Thanks

User avatar
andrew
Site Admin
Posts: 5603
Joined: Fri Mar 30, 2007 6:07 am

Re: Doing layer changes in one operation

Post by andrew » Wed Jun 27, 2018 1:11 pm

Delete layer "layer 1" and make layer "layer 3" the current layer:

Code: Select all

var document=getDocument();
var documentInterface=getDocumentInterface();
var op = new RAddObjectsOperation();
op.deleteObject(document.queryLayer("layer 1"));
var docVars = document.queryDocumentVariables();
docVars.setCurrentLayerId(document.getLayerId("layer 3"));
op.addObject(docVars);
documentInterface.applyOperation(op);

sarlaa
Active Member
Posts: 47
Joined: Mon Aug 28, 2017 4:39 pm

Re: Doing layer changes in one operation

Post by sarlaa » Thu Jun 28, 2018 10:34 am

Thanks

Post Reply

Return to “QCAD Developers and Contributors”