Skip to content

Instantly share code, notes, and snippets.

@jbsarrodie
Created September 14, 2018 18:57
Show Gist options
  • Save jbsarrodie/3cfe6ae90b29696c55550ce3d4b3a577 to your computer and use it in GitHub Desktop.
Save jbsarrodie/3cfe6ae90b29696c55550ce3d4b3a577 to your computer and use it in GitHub Desktop.
#jArchi script to remove bendpoints on selected relationships
// RemoveBentpoints
//
// Requires jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/
//
// This script takes a selection of visual objects as input, filter it to keep only relationships and remove all their bendpoints
//
// (c) 2018 Jean-Baptiste Sarrodie
$(selection).filter("relationship").filter(function(o) {return o.view}).each(function(o) {
var view = o.view;
var rel = o.concept;
var source = o.source;
var target = o.target;
o.delete();
view.add(rel, source, target);
})
@timhale7
Copy link

any advice on how to access the bendpoint attributes? I'd like to create a variant of this script that reverses the direction of the relationship (where allowed) and preserve the endpoints that already established.

@markbacker
Copy link

markbacker commented Mar 26, 2021

This is indeed a very handy script. I use it a lot.

With the new jArchi scripting plugin with GraalVM, it is not working anymore. The filtering function gives a conversion error.

Here a solution that works in both Nashorn and GraalVM :
Replace the first line
$(selection).filter("relationship").filter(function(o) {return o.view}).each(function(o) {
with
$(selection).filter("relationship").filter(function (o) {return (o.id != o.concept.id) }).each(function (o) {

@InceptusSolutions
Copy link

InceptusSolutions commented Aug 17, 2022

Similar to last comment but I have replaced

$(selection).filter("relationship").filter(function(o) {return o.view}).each(function(o) {

with

$(selection).filter("relationship").filter(function(o) {return o.view!=undefined}).each(function(o) {

which seemed simpler.
Also made a couple more changes to preserve the label expression

var labelExpr=o.labelExpression;

newo=view.add(rel, source, target);
newo.labelExpression=labelExpr;

@markbacker
Copy link

With the relative new method deleteAllBendpoints() you can keep the selected relations. No need to restore anything.

Combined with your line this script only removes the bendpoints of the selected relations:

$(selection).filter("relationship").filter(function(o) {return o.view!=undefined}).each(function(o) {
  o.deleteAllBendpoints();
})

@InceptusSolutions
Copy link

Well that's simpler.
I've been using the script a while and never noticed it had been incorporated into the language.
Thanks
(off to update some scripts now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment