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.
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
Hello Abhijit,
I already tried the ff. scenarios but I still ended up with a messy webbings of connection lines:
Scenario 1) On moving the model, I only moved the connections without moving the ObjOcc objects.
Scenario 2) On copying each ObjOcc object of the source model, I simply created a new ObjOcc by using this method and fill it up with parameter values from each ObjOcc object as I did before:
var temp = targetModel.createObjOcc(srcOccurences[i].SymbolNum(), srcOccurences[i].ObjDef(), srcOccurences[i].X(), srcOccurences[i].Y());
Then only on moving the model, I created all the CxnObj objects on the fly with the adjustments already added.
I have a question though.. when I use the createObjOcc() function, I fill it up with an ObjDef object that contains the CxnOcc references... how would I delete the CxnOcc objects or points referenced within an ObjDef?
Hey got a similar issue doing another script, I manage to move all my objects except the connections (type: links in a BPMN collaboration diagram 2.x)
How to obtain an array of those conections (the ones we need save so then we can delete and then remake)?
I am trying getLinks() functions and getConnectedObjOccs but no luck yet