Identifying entities recently added

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

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
sramp
Active Member
Posts: 26
Joined: Mon Dec 02, 2013 4:15 pm

Identifying entities recently added

Post by sramp » Wed Feb 05, 2014 12:29 pm

Hello,
I'm modifying the Line2p.js scritp since I would like to create a new tool able to create automatically a new block built with a closed polygon.
To create the block I need to know the entities which forming the closed polygon.
Is there a way to know the ids of these entities?

I see that the entity is created in the getOperation method, but I suppose that the id of the entity will be assigned after the RAddObjectOperation completion, since here the id is still -1

Code: Select all

 Line2P.prototype.getOperation = function(preview) {
    var line = new RLineEntity(
        this.getDocument(),
        new RLineData(this.point1, this.point2)
    ); 
    return new RAddObjectOperation(line);
};
Thanks
sramp

sramp
Active Member
Posts: 26
Joined: Mon Dec 02, 2013 4:15 pm

Re: Identifying entities recently added

Post by sramp » Thu Feb 06, 2014 11:38 am

Hello,
maybe I've found a solution of my problem.
I have added to my script a RTransactionListenerAdapter.
In this way I can retrieve the ids of the segments while I'm building the closed polygon.
To learn more just study the example script ExTransactionListener.js.

Please let me know if there is a different and better solution.
Thanks
sramp

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

Re: Identifying entities recently added

Post by andrew » Thu Feb 06, 2014 11:46 am

Yes, a transaction listener is the solution to use whenever you need to know what is 'going on' in a drawing. All objects that are added or modified go through a transaction.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”