Hi ARIS Support,
I have this task of copying the contents of one model to a blank model and another task of repositioning all of the copied objects along the y-axis. I was able to do both but for the second task, I was not able to properly retain the original positioning of the copied Connection objects/lines (CxnOcc objects). Here are my codes for the y-position realignment task:
// Relocate all the occurences that are found within a model along the x-axis and y-axis
function adjustOccurencesLocAtXY(model, xIncrement, yIncrement) {
var i, j;
if (model == null) {
Dialogs.MsgBox("Source Model is null or empty");
return;
}
var srcCxnOccurences = model.CxnOccListFilter();
for (i = 0; i < srcCxnOccurences.length; i++) {
var arrPoints = srcCxnOccurences[i].PointList();
for (j = 0; j < arrPoints.length; j++) {
arrPoints[j, 0].setX(arrPoints[j, 0].getX() + xIncrement);
arrPoints[j, 1].setY(arrPoints[j, 1].getY() + yIncrement);
}
var fromExtCxnOccs = srcCxnOccurences[i].fromExtCxnOccs();
for (j = 0; j < fromExtCxnOccs.length; j++) {
fromExtCxnOccs[i].SetPosition(fromExtCxnOccs[i].X() + xIncrement, fromExtCxnOccs[i].Y() + yIncrement);
}
var toExtCxnOccs = srcCxnOccurences[i].toExtCxnOccs();
for (j = 0; j < toExtCxnOccs.length; j++) {
toExtCxnOccs[i].SetPosition(toExtCxnOccs[i].X() + xIncrement, toExtCxnOccs[i].Y() + yIncrement);
}
}
var srcTextOccurences = model.TextOccList();
for (i = 0; i < srcTextOccurences.length; i++) {
srcTextOccurences[i].SetPosition(srcTextOccurences[i].X() + xIncrement, srcTextOccurences[i].Y() + yIncrement);
}
var srcComObjOccurences = model.ComObjOccs();
for (i = 0; i < srcComObjOccurences.length; i++) {
srcComObjOccurences[i].SetPosition(srcComObjOccurences[i].X() + xIncrement, srcComObjOccurences[i].Y() + yIncrement);
}
var srcOccurences = model.ObjOccList();
for (i = 0; i < srcOccurences.length; i++) {
srcOccurences[i].SetPosition(srcOccurences[i].X() + xIncrement, srcOccurences[i].Y() + yIncrement);
}
}
Given my codes above, are there things that I missed out from my repositioning codes or had some unwanted function calls or improper order of function calls? Or is there a shorter and easier way of doing this? That I would love to hear.
Shown below is the original model, the copied model and the relocated model...
Thanks.

Abhijit Das on
Hi Nanji,
It reminds me of my variant copy creation of model for our company.
The resaon it is failing are
1. Although you are relocating the connection at the begining and moving objects later. But since connection are linked with Objects it just retains the connection where it is connected with the object. As a result the connection gets messy. Check only moving the connection without moving the objects.
2. If you are moving the objects first what will happen the coneection still maintain its link with object and get messy.
Theoretically you can do it in the single model but you have to delete the connection and redo the connection and to do that you have to maintain/keep record of object occurence , connection etc in array and reuse it. Although it is complex but it is doable.
I beleive you copied the model with the same principle.
Abhijit Das