Hello,
I have to find all models where function has an occurrence. I'm looking for functions (I'm done with it), but I could not move further. I wanted to use object function OccList(), but how to get models for these occurrences?
Thanks.
Hi Albina,
you could try this
var g_nloc=Context.getSelectedLanguage();
var oselectedObject=ArisData.getSelectedObjDefs();
for(var i=0;i<oselectedObject.length;i++){
var modellist=new Array();
occurentobject=oselectedObject[i].OccList();
for(var j=0;j<occurentobject.length;j++){
if(modellist.contains(occurentobject[j].Model().Name(g_nloc) ) == false){
modellist.push(occurentobject[j].Model().Name(g_nloc));
}
}
}
please import Common files/commonUtils.js otherwise it will give error in contains .
regards
Hi!
There could be models with identical names. It is better to use model GUID as a key or ArisData.Unique() method to ensure models in list are unique.
var oFuncDef = ... var oLV = new Object; var aModels = new __map(); //defined in convertertools.js oLV.aOccs = oFuncDef.OccList(); for (var i=0; i<oLV.aOccs.length; i++) { oLV.oOcc = aOccs[i]; oLV.oModel = oLV.oOcc.Model(); if (!aModels.ContainsKey(oLV.oModel.GUID()) { //This model has not been found yet aModels.Insert(oLV.oModel.GUID(), oLV.oModel); } } delete oLV.aOccs;
Hope, this helps.