Archi Forum

Archi Plug-ins => jArchi => Topic started by: JoCriSem on June 10, 2020, 09:42:41 AM

Title: Adding a 'Note' on the bottom of an export
Post by: JoCriSem on June 10, 2020, 09:42:41 AM
I am looking at a way to add a note on each export As Image.  Ideally that note would be below the lowest element in the view.
Is there a way to achieve this?

Currently I use a script that adds a static note, but if the model extends the coordinates I use, it doesn't look good.
(var note = view.createObject("note", 950, 700, 300, 70);)

Thanks.
Title: Re: Adding a 'Note' on the bottom of an export
Post by: Phil Beauvoir on June 10, 2020, 10:06:08 AM
Have you tried something like iterating through all the elements in the view and finding the y-value of the bounds of each element (element's y value plus its height), getting the largest value, and then adding the note below that?
Title: Re: Adding a 'Note' on the bottom of an export
Post by: JoCriSem on June 10, 2020, 10:17:55 AM
Thanks Phil.  I haven't tried that yet.
How would I go about doing that exactly?
Title: Re: Adding a 'Note' on the bottom of an export
Post by: projetnumero9 on June 10, 2020, 10:34:51 AM
Quote from: Phil Beauvoir on June 10, 2020, 10:06:08 AM
Have you tried something like iterating through all the elements in the view and getting the greatest y-value of its bounds (element's y value plus its height) and then adding the note below that?

I was thinking about suggesting that (and the gist https://gist.github.com/jbsarrodie/9784e2035d0e6599a8a7a890ba8c63cd would if necessary be a good start to iterate), but one would add : what about bendpoints? I have to admit I have difficulty wrapping my head around: https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#relativebendpoints

For example,
- x=0 and y=0 being the top left corner in the print screen attached,
- coordinate and size of my source being: {x: 150, width: 110, y: 190, height: 250}
- bendingpoint having the following value:  [{endY=-50, endX=-330, startY=-50, startX=-90}]
, how do I calculate the coordinate of my bendpoint? (I haven't thoroughly studied https://gist.github.com/jbsarrodie/3cfe6ae90b29696c55550ce3d4b3a577 yet)
Title: Re: Adding a 'Note' on the bottom of an export
Post by: Phil Beauvoir on June 10, 2020, 14:37:39 PM
Quote from: JoCriSem on June 10, 2020, 10:17:55 AM
Thanks Phil.  I haven't tried that yet.
How would I go about doing that exactly?

This might help:


var view = selection.first();
var maxX = 0;
var maxY = 0;

$(view).children().filter("element").each(function(element) {
    var bounds = element.bounds;
   
    var x = bounds.x + bounds.width;
    if(x > maxX) {
        maxX = x;
    }

    var y = bounds.y + bounds.height;
    if(y > maxY) {
        maxY = y;
    }
});

var note = view.createObject("note", maxX + 10, maxY + 10, 300, 70)
Title: Re: Adding a 'Note' on the bottom of an export
Post by: Phil Beauvoir on June 10, 2020, 14:39:37 PM
@projetnumero9 Have a look at this discussion, it might offer some clues - https://github.com/archimatetool/archi-scripting-plugin/issues/42
Title: Re: Adding a 'Note' on the bottom of an export
Post by: projetnumero9 on June 10, 2020, 15:47:26 PM
Thanks for the pointer,
;)
Title: Re: Adding a 'Note' on the bottom of an export
Post by: JoCriSem on June 11, 2020, 12:52:37 PM
Incorporated it in my script, applied a few tweaks on the positioning and it works super.

Many thanks.