Page 1 of 1

Identifying entities recently added

Posted: Wed Feb 05, 2014 12:29 pm
by sramp
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

Re: Identifying entities recently added

Posted: Thu Feb 06, 2014 11:38 am
by sramp
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

Re: Identifying entities recently added

Posted: Thu Feb 06, 2014 11:46 am
by andrew
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.