Archi Forum

Archi Plug-ins => jArchi => Topic started by: Marco on March 30, 2020, 16:10:48 PM

Title: (custom) Properties export to excel
Post by: Marco on March 30, 2020, 16:10:48 PM
Hi,

Just started today with JArchi, running some scripts that are very helpful. For Application Lifecycle Management a would like to add several custom properties to an ApplicationComponent. Need some guidance on how to build a script that exports all elements from a particular view and includes the custom properties of the element.

Already look into the export to excel script ant export to markdown script and try to combine the two because the markdown is selecting the custom properties... But I'am not a developer so this would take me ages. So I need som help!!! 

Kind regards, Marco
Title: Re: (custom) Properties export to excel
Post by: Jean-Baptiste Sarrodie on March 30, 2020, 18:35:04 PM
Hi,

Not exactly sure of what you're trying to achieve, but here is a script that will iterate on each element in the current view and will print the view name, element name, and an arbitrary chosen set of properties:


var view = selection.filter('archimate-diagram-model').first();

console.show();
console.clear();

console.log("View Name,Element Name,Key1,Key2,Key3");

$(view).find('element').each(function(e) {
  var propKey1 = e.prop('Key1');
  var propKey2 = e.prop('Key2');
  var propKey3 = e.prop('Key3');
 
  console.log(view.name, ',', e.name, ',', propKey1, ',', propKey2, ',', propKey3);
});


To run it simply right clic on a view (not an element of this view) and run this script from the context menu.

Regards,

JB
Title: Re: (custom) Properties export to excel
Post by: Marco on March 30, 2020, 18:56:21 PM
Hi JB,

Thnx for the quick response.... this is working!
Is it possible that you can add an export function to excel? ;-)
Or show me how it is written then a try to compose it myself > and getting en learningcurve

Kind regards,

Marco
Title: Re: (custom) Properties export to excel
Post by: Jean-Baptiste Sarrodie on March 30, 2020, 19:21:33 PM
Hi,

You can use the example script ("Export to Excel")provided with jArchi. Change the headers on lines 37-40, update line 59-63 to reflect my snippet and this should work.

Another option is to simply display the result in CSV format on the console (like in my snippet) and then copy/paste it to Excel ;-) You might have to change separator though.

Regards,

JB