Hi All,
I'm trying to programmatically create a connection between 2 objects. I've created a script which detects if the objects overlap, and then I want to create the connection using CreateCxnOcc. I've tried a few different options, but can't seem to get the connection created.
Even if I go to a basic EPC model and select an Event and a Function, and use the below code the connection isn't created - I feel like I must be doing something wrong!
I'm not a programming expert by any stretch but can generally get by, so appreciate the help and sorry if I'm missing some basics.
var objects = ArisData.getSelectedObjOccs(); var model = objects[0].Model(); var cnx = model.CreateCxnOcc(false,objects[1],objects[0],Constants.CT_ACTIV_1,null);
Robert Goldenbaum on
Hi Scott,
well, you need a point list for a cxn occ (meaning an occurrence of a connection in a model). So you need the start point, the end point and also a point for every corner...
If you want to create nested objects, I don't think you have to create a cxn occ. A cxn def could be enough...
An example to create a connection follows below...
naPointList = GetPointList(oAWSTOcc_New, oNewObjOcc);
oCxnOcc = oSyncModel.CreateCxnOcc(oAWSTOcc_New, oNewObjOcc, Constants.CT_CAN_SUPP_1, naPointList, false, false);
function GetPointList(oSrc, oTrg){
var oPointList = new Array();
var oPoint = null;
var oPoint2 = null;
var oPoint3 = null;
var oPoint4 = null;
// oPoint = new java.awt.Point(oSrc.X() + oSrc.Width(), oSrc.Y() + oSrc.Height() / 2);
// oPoint2 = new java.awt.Point(oSrc.X() + oSrc.Width() + (oTrg.X() - (oSrc.X() + oSrc.Width())) / 2, oSrc.Y() + oSrc.Height() / 2);
// oPoint3 = new java.awt.Point(oSrc.X() + oSrc.Width() + (oTrg.X() - (oSrc.X() + oSrc.Width())) / 2, oTrg.Y() + oTrg.Height() / 2);
// oPoint4 = new java.awt.Point(oTrg.X(), oTrg.Y() + oTrg.Height() / 2);
// oPointList.push(oPoint);
// oPointList.push(oPoint2);
// oPointList.push(oPoint3);
// oPointList.push(oPoint4);
oPoint = new java.awt.Point(oSrc.X(), oSrc.Y() + oSrc.Height() / 2);
oPoint2 = new java.awt.Point(oTrg.X() + oTrg.Width(), oTrg.Y() + oTrg.Height() / 2);
oPointList.push(oPoint);
oPointList.push(oPoint2);
return oPointList;
}