Identifying entities recently added

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

Moderator: andrew

Identifying entities recently added

Postby 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

Postby 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
sramp
Active Member
 
Posts: 26
Joined: Mon Dec 02, 2013 4:15 pm

Re: Identifying entities recently added

Postby 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.
User avatar
andrew
Site Admin
 
Posts: 2557
Joined: Fri Mar 30, 2007 6:07 am


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: No registered users and 0 guests

cron