Author Topic: Scripting Views  (Read 496 times)

bigyin

  • Active Member
  • ***
  • Posts: 30
Scripting Views
« 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
« Last Edit: April 15, 2020, 12:26:10 PM by bigyin »

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1619
  • Code Punk
    • Archi
Re: Scripting Views
« Reply #1 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).
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

bigyin

  • Active Member
  • ***
  • Posts: 30
Re: Scripting Views
« Reply #2 on: April 15, 2020, 14:22:12 PM »
Not folders, (have that based on your previous help) but the grouping (grey box) for readability..

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1619
  • Code Punk
    • Archi
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

bigyin

  • Active Member
  • ***
  • Posts: 30
Re: Scripting Views
« Reply #4 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)

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1619
  • Code Punk
    • Archi
Re: Scripting Views
« Reply #5 on: April 15, 2020, 15:47:45 PM »
You have to add the concept to the group. For example:

Code: [Select]
// 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);
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Phil Beauvoir

  • Administrator
  • Hero Member
  • *****
  • Posts: 1619
  • Code Punk
    • Archi
Re: Scripting Views
« Reply #6 on: April 15, 2020, 15:49:03 PM »
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

bigyin

  • Active Member
  • ***
  • Posts: 30
Re: Scripting Views
« Reply #7 on: April 15, 2020, 15:49:57 PM »
Thanks. One Step at a time ...

Jean-Baptiste Sarrodie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 716
  • Archi Evangelist and Contributor. Visionary.
    • About me...
Re: Scripting Views
« Reply #8 on: April 15, 2020, 19:23:56 PM »
Hi,

For layout, you can leverage existing JavaScript libraries like 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
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate