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.

 

 or register to reply.

Notify Moderator