I added this question to another Post (https://www.ariscommunity.com/users/hessphilipp/2010-02-04-symbol-attribute-object-aris-report-script#comment-27487), but it was an old post so I thought I would also add this New Post.

Wondering if anyone can help with a problem I am having. I have some very simple code (see below) to report (from 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 come out in a DIFFERENT ORDER from th eloop 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. It seems to have something to do with having to get some information from the Object Definition Method and some of the information from the Object Occurrence Method I think, but I can't figure it out. Any help would be much appreciated.

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;
}
    

Tags: ARIS Report Scripting