Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Paolo F Cantoni on December 03, 2018, 12:40:36 pm

Title: Selected Objects Collection Order
Post by: Paolo F Cantoni on December 03, 2018, 12:40:36 pm
We are reinvestigating Visual Enclosure with some scripts to help with the relationships between the enclosed and enclosing objects.

We have observed that the selected objects collection seems to have a special property.  The objects in the collection appear to be returned in reverse Z-Order.

Is this intentional?  Can we rely on this behaviour?  It seems eminently reasonable that they are returned in that order.  If we can rely on this behaviour we can simplify our code tremendously and determine enclosure in one pass.

TIA,
Paolo
Title: Re: Selected Objects Collection Order
Post by: Eve on December 06, 2018, 01:56:04 pm
I'd say that the order is a product of the internal ordering rather than something official.

That said, I can't see a reason why it would be changed.

PS. Looking for a single object enclosing "the rest" of the selection?
Title: Re: Selected Objects Collection Order
Post by: Paolo F Cantoni on December 06, 2018, 02:59:36 pm
I'd say that the order is a product of the internal ordering rather than something official.

That said, I can't see a reason why it would be changed.

PS. Looking for a single object enclosing "the rest" of the selection?
More general - looking for objects visually enclosing other objects.  In the selection, there may be more than one set of enclosures.

Paolo
Title: Re: Selected Objects Collection Order
Post by: Eve on December 07, 2018, 08:58:18 am
Then you'll still require multiple passes through the list won't you? Check each object against all possible parents/children. You can optimize by starting after the element you're checking, but I can't see that you'll only need a single pass.
Title: Re: Selected Objects Collection Order
Post by: Paolo F Cantoni on December 07, 2018, 09:20:59 am
Then you'll still require multiple passes through the list, won't you? Check each object against all possible parents/children. You can optimize by starting after the element you're checking, but I can't see that you'll only need a single pass.
Neither did we, initially, but the algorithm seems to work.  It doesn't calculate the enclosure level correctly, but it DOES figure out who is enclosed by whom.

When we're done, I'll post here.

Paolo