To make my question more clear, I'd like to add a fragment of the report script:
----------------------------------------------------------------------------------------------
for (var i=0;i<arrayOfObjOccs.length;i++) { var objOccSymbol = arrayOfObjOccs[i].ObjDef().Attribute(Constants.AT_PEM_SYMOL_EXCEPT, nLocale).GetValue(false)) if (objOccSymbol == Constants.ST_FUNC) { ... //do something } //end if } //next for
-----------------------------------------------------------------------------------------------
I'm unable to use the Model.getObjOccFilter() (or similar functions) because I explicitly need the the content of the Array in the sequence as it is.Does anybody know which attribute can be used to determine the symbol of objects or if there's any other possibility? Thank you in advance for your help!
Hi Mr. Hess,
it's much easier. The ObjOcc provides access to its symbol directly:
for (var i=0;i<arrayOfObjOccs.length;i++) { if (arrayOfObjOccs[i].getSymbol() == Constants.ST_FUNC) { ... //do something } //end if } //next for -----------------------------------------------------------------------------------------------
If you are not using default symbols but user-defined symbols, you use the method getSymbolGUID() instead of getSymbol().
Wondering if you can help with a problem I am having. I have some very simple code (below) to report (Group or Model focus) Objects on Models including Model Path, Object Path, and Object Type which come from the ObjDefList. Where I am having a problem is I want to include the Object Symbol. I get the Symbols using the ObjOccList.
The problem is the Object Symbols are in a DIFFERENT ORDER than the Object Name and Type.
Is there are way to do this correctly? I have been doing a lot of searching and trying different things without success. Thanks.
var output = Context.createOutputObject();
main();
function main() {
output.BeginTable(150, Constants.C_BLACK, Constants.C_WHITE, Constants.FMT_LEFT | Constants.FMT_ITALIC, 0);
output.TableRow();
output.TableCell("Model Path", 75, "Arial", 10, Constants.C_BLACK, Constants.C_LIGHT_BLUE, 0, Constants.FMT_LEFT | Constants.FMT_BOLD, 0);
output.TableCell("Model Name", 25, "Arial", 10, Constants.C_BLACK, Constants.C_LIGHT_BLUE, 0, Constants.FMT_LEFT | Constants.FMT_BOLD, 0);
output.TableCell("Object Path", 75, "Arial", 10, Constants.C_BLACK, Constants.C_LIGHT_BLUE, 0, Constants.FMT_LEFT | Constants.FMT_BOLD, 0);
output.TableCell("Object Name", 50, "Arial", 10, Constants.C_BLACK, Constants.C_LIGHT_BLUE, 0, Constants.FMT_LEFT | Constants.FMT_BOLD, 0);
output.TableCell("Object Type", 25, "Arial", 10, Constants.C_BLACK, Constants.C_LIGHT_BLUE, 0, Constants.FMT_LEFT | Constants.FMT_BOLD, 0);
output.TableCell("Object Symbol", 25, "Arial", 10, Constants.C_BLACK, Constants.C_LIGHT_BLUE, 0, Constants.FMT_LEFT | Constants.FMT_BOLD, 0);
var oModels = getRelevantModels();
for(var x = 0; x < oModels.length; x++)
{
var groupPath = oModels[x].Group().Path(Context.getSelectedLanguage());
var modelName = oModels[x].Name(Context.getSelectedLanguage());
var cModel = oModels[x]; // Current model
var aObjDefs = cModel.ObjDefList(); // All object definitions that have occurrences in the model
var ObjOcc = cModel.ObjOccList(); // Occurrences of All Object on model
for (var j = 0; j < aObjDefs.length; j++) // Loop through the object definitions
{
var oObjDef = aObjDefs[j]; // Current object definition
var sObjName = oObjDef.Name(Context.getSelectedLanguage()); // Name of current object
var sObjPath = oObjDef.Group().Path(Context.getSelectedLanguage()) // Group/Path of current object
var sObjType = oObjDef.Type() // Type of current object
var sObjSym = ObjOcc.SymbolName() // Default Symbol of current object
output.TableRow();
output.TableCell(groupPath.replace("Main group\\", ""), 75, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0);
output.TableCell(modelName, 25, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0);
output.TableCell(sObjPath, 75, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0);
output.TableCell(sObjName, 50, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0);
output.TableCell(sObjType, 25, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0);
output.TableCell(sObjSym, 25, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0);
} // for (var j...Object definitions
} // for (var x...Models
output.EndTable("Model Object Occurrences", 100, "Arial", 10, Constants.C_BLACK, Constants.C_BLACK, 0, Constants.FMT_LEFT | Constants.FMT_ITALIC, 0);
output.WriteReport();
}
function getRelevantModels() {
var selectedModels = ArisData.getSelectedModels();
if (selectedModels.length == 0) {
var selectedGroups = ArisData.getSelectedGroups();
for (var i = 0; i < selectedGroups.length; i++) {
var oRelevantModels = selectedGroups[i].ModelList(true);
if (oRelevantModels.length > 0) {
selectedModels = selectedModels.concat(oRelevantModels);
}
}
}
return selectedModels;
}
// Reads all Object Occurrences linked to these objects
// @param {Object} oObjectDefList The object definition list
//
function collectObjOccs(oObjectDefList){
var result = new Array();
for(var i=0; i<oObjectDefList.length; i++){
result = result.concat(oObjectDefList[i].OccList())
}
return ArisData.Unique(result)
}
var aObjDefs = cModel.ObjDefList(); // All object definitions that have occurrences in the model
var ObjOcc = cModel.ObjOccList(); // Occurrences of All Object on model
for (var j = 0; j < aObjDefs.length; j++) // Loop through the object definitions
{
var oObjDef = aObjDefs[j];
At this point do not take the Occ-List of the model. Remember that some objects might have multiple Occs in the model.
var aObjOccs = oObjDef.OccListInModel(cModel);
Now you can iterate the Occs of the Object to find all Symbols of the object in the model. If you are lucky, it's always the same.
Your code comment suggests though, that you are looking for the default symbol of the object. That is not part of the Occ, but the objDef. You get it via
oObjDef.getDefaultSymbolNum();
Side note: You get better visibility, if you do not reply to 11-year-old posts, but create a new one.
Thanks for replying so quickly. I see you also commented on my New Post so I will reply and explain on that New Post ( ( https://www.ariscommunity.com/comment/27491#comment-27491 ).