Detect layer changes

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

Detect layer changes

Post by sarlaa » Tue Jun 26, 2018 1:27 pm

Hi,

Please, how can I detect layer changes information of a transaction ? (new layer added, removed, or setted as current)

Thanks

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

Re: Detect layer changes

Post by andrew » Tue Jun 26, 2018 3:03 pm

I've updated the transaction listener example to show information about created / deleted objects:
https://github.com/qcad/qcad/blob/maste ... istener.js

You can check if an object is a layer using isLayer(obj).

For the current layer, you can look into the changed objects using a transaction listener, or install a separate layer listener:

Code: Select all

var adapter = new RLayerListenerAdapter();
appWin.addLayerListener(adapter);
adapter.currentLayerSet.connect(this, "myFunction");

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

Re: Detect layer changes

Post by sarlaa » Tue Jun 26, 2018 3:22 pm

Thanks for your examples.

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

Re: Detect layer changes

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

What's the property's constant of : RPropertyTypeId(18, "", "", "", "Current Layer ID") ?
(as RTextEntity.PropertyPositionX for RPropertyTypeId(53, "", "", "Text Position", "X") )

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

Re: Detect layer changes

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

Code: Select all

REntity.PropertyLayer
These constants are defined in the respective object or entity classes:
https://github.com/qcad/qcad/blob/maste ... /REntity.h
https://github.com/qcad/qcad/blob/maste ... xtEntity.h
etc.

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

Re: Detect layer changes

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

Thanks

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

Re: Detect layer changes

Post by sarlaa » Fri Jul 06, 2018 3:03 pm

REntity.PropertyLayer is constant for : RPropertyTypeId(5, "", "", "", "Layer")
when I need constant of : RPropertyTypeId(18, "", "", "", "Current Layer ID")

Thanks.

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

Re: Detect layer changes

Post by sarlaa » Fri Jul 06, 2018 3:08 pm

I found it RDocumentVariables.PropertyCurrentLayerId.

Thanks.

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

Re: Detect layer changes

Post by andrew » Fri Jul 06, 2018 3:22 pm

RDocumentVariables.PropertyCurrentLayerId

See https://github.com/qcad/qcad/blob/maste ... ariables.h

Post Reply

Return to “QCAD Developers and Contributors”