When you move an object to another layer, the object's relations do not automatically move with the object to the new layer. They stay in the original layer. You need to manually select the relations and move them to the new layer to keep them with their object.

If you do not want to move these relations manually one by one, you can use the script below to move all relations at once to their new layer. Run the script after you have moved the objects. The script will move the relations to the same layer of the "from-object".


message "Looking for relations to move...";
checked = 0;
moved = 0;
forall "ArchiMateMM_Model" m in modelpackage {
	relations = m.allChildren("AbstractRelation");
	if (relations.empty()) {
		continue;
	}
	if (m.isReadOnly()) {
		message "Model '" + m.name() + "' has relations, but is skipped because it is out-of-scope/read-only.", m;
		continue;
	}
	message "Moving relations in model '" + m.name() + "'...", m;
	forall r in relations {
		checked = checked + 1;
		fromScheme  = r.from.parent("AbstractScheme");
		toScheme = r.to.parent("AbstractScheme");
		if (fromScheme.isUndefined() && toScheme.isUndefined()) {
			message "Relation '" + r.name() + "' is not moved because it belongs where it is currently located.", r;
			continue;
		}
		scheme = fromScheme;
		if (scheme.isUndefined() || scheme.isReadOnly()) {
			scheme = toScheme;
			if (scheme.isUndefined() || scheme.isReadOnly()) {
				warning "Relation '" + r.name() + "' is not moved because both ends are out-of-scope/read-only or unavailable.", r;
				continue;
			}
		}
		r.moveTo(scheme);
		moved = moved + 1;
		message "Moved relation '" + r.name() + "' to layer '" + scheme.name() + "'.", r;
	}
}
if (checked > 0) {
	message "Done. Found " + checked + " relations, moved " + moved + " of them.";
}
else {
	message "Done. Found no relations to move.";
}