Hello every one i'm new to ARIS I have to print function tree object with different level in Excel file with the help of script.I have attached my model and output file that i have reqired.Thanks in advance.
The following code should work. Put it in a report and set the context of the report to the Function Tree model type. Output should be Excel.
var g_nLoc = Context.getSelectedLanguage(); var g_oOutfile = Context.createOutputObject(); // Define style g_oOutfile.DefineF("Standard", "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0, 0, 0, 0, 0, 0); function main() { var aoObjOccs = ArisData.getSelectedModels()[0].ObjOccList(); if (aoObjOccs.length > 0) { // Determine root objects var aoRoots = []; for (var i=0; i<aoObjOccs.length; i++) { var oObjOcc = aoObjOccs[i]; if (oObjOcc.InEdges(Constants.EDGES_ALL).length == 0) aoRoots.push(oObjOcc); } // Determine table width and write header (10 columns hardcoded) var anColumns = []; for (var i=0; i<10; i++) anColumns.push(10.0); g_oOutfile.BeginTable(100, anColumns, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0); g_oOutfile.TableRow(); for (var i=1; i<=10; i++) g_oOutfile.TableCellF("Level "+i, 1, 1, "Standard"); g_oOutfile.TableRow(); // Write out the tree data for (var i=0; i<aoRoots.length; i++) { writeTree(aoRoots[i], 1, i>0); } } g_oOutfile.EndTable("", 100, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0); g_oOutfile.WriteReport(); } function writeTree(p_oRoot, p_nLevel, p_bNewlineAndIndent) { if (p_bNewlineAndIndent) { g_oOutfile.TableRow(); for (var i=1; i<p_nLevel; i++) g_oOutfile.TableCellF("", 1, 1, "Standard"); } // Insert the root's name g_oOutfile.TableCellF(p_oRoot.getObjDefName(-1), 1, 1, "Standard"); // Get and insert the root's children var aoChildren = p_oRoot.getConnectedObjOccs(null, Constants.EDGES_OUT); for (var i=0; i<aoChildren.length; i++) { writeTree(aoChildren[i], p_nLevel+1, i>0); } } main();