archimatetool / archi

Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
MIT License
952 stars 268 forks source link

Export selected objects #955

Closed HansBosma closed 1 year ago

HansBosma commented 1 year ago

Is it possible to export a selection of objects? It would be nice to have an export of objects in some folder (so export all objects within folder). Or does an jArchi script already exists for this functionality?

Phillipus commented 1 year ago

Hi, what export format did you have in mind?

HansBosma commented 1 year ago

Oh yes sorry, just the ordinary csv-export. And I am already happy with just the 'elements' csv format.

Phillipus commented 1 year ago

Hi, the CSV export implementation exports all elements, relations, and properties for the whole model so it would be difficult to re-write that code for a specific use case. There may be a jArchi script out there that does this, though.

HansBosma commented 1 year ago

Yes I know, I was hoping I could have / find that script 'out there'... Or maybe that it is simple to change the standard script to work only on a selection of objects but I am not able to change the script in this way.

Phillipus commented 1 year ago

but I am not able to change the script in this way.

Which script are you using?

HansBosma commented 1 year ago

The examples jArchi script (is the same as the standard export functionality in Archi I presume?)

Phillipus commented 1 year ago

The examples jArchi script

I guess you mean the "Export to Excel" one. If so, you could change this part:

$("element").each(function(e) {
    excel.set(0, 0, current_row, e.name);
    excel.set(0, 1, current_row, e.documentation);
    excel.set(0, 2, current_row, e.id);
    excel.set(0, 3, current_row, e.type);
    excel.set(0, 4, current_row, e.specialization == null ? "" : e.specialization);

    current_row++;
});

Instead of using $("element") as the selector ("all elements") you could change it to get the currently selected folder and all elements in that folder.

If you get stuck, it's probably best to discuss on the Archi Forum, as there are some jArchi experts who might offer some advice.

HansBosma commented 1 year ago

yes I also looked into that and had that idea also. But what is the change I have to maken by replacing $("element") ? Into what? If that is one change, I can make that change but I do not know the command 'selecting objects within current folder'.

Phillipus commented 1 year ago

Assuming that you select a folder in the models tree, the jArchi selection will give you the selected folder. Then you can use children to get the child elements:

selection.children().each(function(e) {

(Reference - https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Collection)

HansBosma commented 1 year ago

Magnificent! I did not know where to look, and it works now. Thank's a lot!!

Phillipus commented 1 year ago

You're welcome. If you do get into jArchi more, please do discuss on the Archi Forum! :-)