Hi,
I am developing a small script that should be able to import excel data and generate a model.
However, I am unable to get connections between some objects of specific types, even though these connections can be created in the "Designer" module.
Concrete illustration of my problem:
As you can see, there are some links missing. It WOULD work if the "Position" would be, for example, a "Function".
I try to connect (all) the objects with the following function:
function connect (source, target) {
// This function "brute force" connects two objects
var i = 0;
var connection = null;
while(!connection && i < 1000) {
connection = model.CreateCxnOcc(true, source, target, i++, pointList);
}
//if(!connection) Dialogs.MsgBox("Still no connection")
}so I think we can exclude that I chose the wrong CxnType (Type number of the relationship occurrence to be created -- in this case: i).
So, has anybody got an idea what could be the problem or has a different solution / workaround for this?
If you need some more code, please feel free to ask!
Many thanks,
Laurent


Ellen Gambrell Pelletier on
Hi Laurent -
Why are you not just setting the connection type in the code rather than iterating through 1000 connection types? This should work:
function connect (model, source, target) { var cxnType = null; var connection = null; var sourceType = source.ObjDef().TypeNum(); var targetType = target.ObjDef().TypeNum(); if ((sourceType == Constants.OT_EVT) && (targetType == Constants.OT_FUNC)) { // Event >> activates (43) >> Function cxnType = Constants.CT_ACTIV_1; } else if ((sourceType == Constants.OT_PERS_TYPE) && (targetType == Constants.OT_FUNC)) { // Person Type >> carries out (218) >> Function cxnType = Constants.CT_EXEC_2; } else if ((sourceType == Constants.OT_POS) && (targetType == Constants.OT_FUNC)) { // Position >> carries out (65) >> Function cxnType = Constants.CT_EXEC_1; } if (cxnType != null) { connection = model.CreateCxnOcc(true, source, target, cxnType, pointList); } return; }