Author Topic: Archimate concept/element/diagram object size and position query in jArchi  (Read 196 times)

Manj75

  • Senior Member
  • ****
  • Posts: 176
Is it possible to return the position and size of a object in jArchi as I've not been able to find a method on the Wiki.  All you can do is specify position and size when creating, i.e. x, y, width, height.

There should be something like:

Code: [Select]
var object = selection.filter(selector)

console.log("object position is x: " + object.posx + " y:" + object.posy + ", size is width: " + object.width + " height:" + object.height)

OR return in JSON object

var objectProperties = selection.filter(selector)
objectProperties.x_position
objectPropeties.y_position
objectProperties.width
objectProperties.height

Returns:

{
   x_position:<number>
   y_position:<number>
   width: <number>
   height: <number>
}

If this is already possible then please can you show me, otherwise this would be really useful to add support - let me know if I should raise a feature issue.

projetnumero9

  • Member
  • **
  • Posts: 18
If I understood properly your usecase, you could achieve it with:
Code: [Select]
// 
// Get Coordinates 
// 
// Quick and dirty coordinates and graphical object dimensions, extraction 
// 
 
// # Main 
// Clear the console for any new message which may occur 
console.show(); 
console.clear(); 
 
//  - for each selected objects, 
selection.each(function(selectedElement) { 
    //    - Print to the console their coordinates, width and height 
    console.log(selectedElement.name, ": ",selectedElement.bounds); 
}); 

Going one step further would then be:
Code: [Select]
selectedElement.bounds.x, etc.

Manj75

  • Senior Member
  • ****
  • Posts: 176
Perfecto  :) :)

Exactly what I was after - having seen your code I re-read the wiki and found .bounds with description of 'Get/set the bounds...', but the snippet code only shows for setting object to bounds, hence why I missed it.

The Wiki guide can do with more detail and examples for all permutation of usage consistently stating the Getter and Setter variant and return value/object.  I know this is open for all to edit and I'll try to work through, but have been hesitant as I don't want to mess it up.  Phil/JB is there an edit->review process for the Wiki or are all edits issued and made public?

Btw - thank you projetnumero9

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1639
  • Code Punk
    • Archi
The Wiki guide can do with more detail and examples for all permutation of usage consistently stating the Getter and Setter variant and return value/object.  I know this is open for all to edit and I'll try to work through, but have been hesitant as I don't want to mess it up.  Phil/JB is there an edit->review process for the Wiki or are all edits issued and made public?

Opening an issue on GH would work.

I've added a getter example of bounds to the wiki.
« Last Edit: August 24, 2021, 16:36:26 PM by Phil Beauvoir »
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate