Archi Forum

Archi Plug-ins => jArchi => Topic started by: bigyin on April 15, 2020, 11:38:11 AM

Title: Scripting Views
Post by: bigyin on April 15, 2020, 11:38:11 AM
Would be grateful for a few pointers:
Scripting the creation of service model that links to a selected capability, and generating a) a view for each service and b) an updated Service model showing all that link to the capability.

Questions
- I want to use Grouping around some concepts - cant seem to find the correct JArch commands
- As I can be sure how many services etc, doing a fixed layout is difficult, is there any JArchi Commands to do auto layout (beautify etc)

Any other pointers in this direction gratefully received, as I am learning better by example
Title: Re: Scripting Views
Post by: Phil Beauvoir on April 15, 2020, 12:33:45 PM
By "grouping" do you mean adding concepts to folders? If so, see https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#add

Or do you mean creating a visual Group in a View? See https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#createobject

There are no commands in core jArchi for auto-layout. Perhaps someone else has written a script for this? If not, then it would be possible for someone to write one (not my speciality, I'm afraid).
Title: Re: Scripting Views
Post by: bigyin on April 15, 2020, 14:22:12 PM
Not folders, (have that based on your previous help) but the grouping (grey box) for readability..
Title: Re: Scripting Views
Post by: Phil Beauvoir on April 15, 2020, 14:28:46 PM
OK, for Groups see https://github.com/archimatetool/archi-scripting-plugin/wiki/jArchi-Object#createobject
Title: Re: Scripting Views
Post by: bigyin on April 15, 2020, 15:32:53 PM
Sorry to be a pain.

I am able to create the group as shown, what I ant to do is include series of elements e.g grouping all business services in a Group, or all the application services etc. While I can paint one on top of the other it does not mean they are included within, hence move with it, as would be the case when i do it manually.

Trying to block bits of the view (dynamically)
Title: Re: Scripting Views
Post by: Phil Beauvoir on April 15, 2020, 15:47:45 PM
You have to add the concept to the group. For example:


// Select first view
var view = selection.first();
// Create and add a group
var group = view.createObject("group", 10, 200, -1, -1);
// Create a Business Actor concept and add to model
var actor = model.createElement("business-actor", "Oscar");
// Add this to the Group
group.add(actor, 10, 10, -1, -1);
Title: Re: Scripting Views
Post by: Phil Beauvoir on April 15, 2020, 15:49:03 PM
Here are some more examples - https://gist.github.com/search?utf8=%E2%9C%93&q=%23jarchi+extension%3Aajs&ref=searchresults
Title: Re: Scripting Views
Post by: bigyin on April 15, 2020, 15:49:57 PM
Thanks. One Step at a time ...
Title: Re: Scripting Views
Post by: Jean-Baptiste Sarrodie on April 15, 2020, 19:23:56 PM
Hi,

For layout, you can leverage existing JavaScript libraries like dagre (https://github.com/dagrejs/dagre).

You can also look at Herve's script which uses dagre and other libraries: https://forum.archimatetool.com/index.php?topic=639.msg3563

Regards,

JB