Is there an existing report that will produce the model graphic and find assigned models and produce their graphic as well? It looks like the Create Process Manual report should do it, I thought I had use it for this before, but I only get the selected model no matter how many assignment levels I enter.
6 Replies
-
I'm not sure if there is an existing report which does exactly what you describe. But if I understand you in the correct way, you want to output the graphics of a model with all its assignments, right?
The tutorials "Output picture of model in Microsoft Excel" describes how to output a model graphic. If you add these lines to the reports:
var oFuncDefs = oModel.ObjDefListFilter(Constants.OT_FUNC); for (var k = 0; k < oFuncDefs.length; k++) { var oFuncDef = oFuncDefs[k]; var oAssignedModels = oFuncDef.AssignedModels(); for (var j = 0; j < oAssignedModels.length; j++) { var oAssModel = oAssignedModels[j]; var sheet = workbook.createSheet(oAssModel.Name(g_nLoc)); pictureOfModel(oAssModel,sheet); } }
you will obtain the required output.
Below is the complete script code.
var g_nLoc = Context.getSelectedLanguage(); var models = ArisData.getSelectedModels(); var workbook = Context.createExcelWorkbook(Context.getSelectedFile()); var dummyOutput = Context.createOutputObject(); main(); dummyOutput.WriteReport() //otherwise it would overwrite the excel output! workbook.write(); function main(){ for(var i=0;i<models.length;i++){ var oModel = models[i]; var sheet = workbook.createSheet(oModel.Name(g_nLoc)); pictureOfModel(oModel,sheet); var oFuncDefs = oModel.ObjDefListFilter(Constants.OT_FUNC); for (var k = 0; k < oFuncDefs.length; k++) { var oFuncDef = oFuncDefs[k]; var oAssignedModels = oFuncDef.AssignedModels(); for (var j = 0; j < oAssignedModels.length; j++) { var oAssModel = oAssignedModels[j]; var sheet = workbook.createSheet(oAssModel.Name(g_nLoc)); pictureOfModel(oAssModel,sheet); } } } } function pictureOfModel(oModel, sheet) { var pic = oModel.Graphic(false,false,g_nLoc); var sfileName = oModel.GUID() + ".png"; var width = pic.getWidth(Constants.SIZE_PIXEL ) * 20 * (100.0/125.0) //twips, correction factor because of excel anomaly (X): * (100.0/125.0) var xCells = width / 1024; var xTwips = width % 1024; var height = pic.getHeight(Constants.SIZE_PIXEL ) * 20*(100.0/133.0) //twips, correction factor because of excel anomaly (Y): \*(100.0/133.0)*/ var yCells = height / 256; var yTwips = height % 256; pic.setZoom(150) // image improvement only(optional) pic.Save(dummyOutput, sfileName); var data = Context.getFile(sfileName, Constants.LOCATION_OUTPUT); sheet.setPicture ( data, 0, 4, 0+xCells, 4+yCells, 0, 0, xTwips, yTwips); Context.deleteFile(sfileName); }
Regards
Eva -
Hi Eva,
I implemented you sctipt and it works completely fine. Need your help in 1 last thing, if you could guide me how to increase the depth level of assignements being captured in the excel. Right now, its picking only one level down. I would like the report to drill down futher assignments level like-
4
4.1
4.1.1
Hoping to hear from you soon..
Cheers,
Tarun R.
-
Hi,
I've added a recursion to the script so you can define how many levels you want to export to the excel workbook.
BR,
Torstenvar g_nLoc = Context.getSelectedLanguage(); var models = ArisData.getSelectedModels(); var workbook = Context.createExcelWorkbook(Context.getSelectedFile()); var dummyOutput = Context.createOutputObject(); var MAXLEVEL = 2; //a maximum depth to reduce script runtime and sheet count :) var setWrittenModels = new java.util.HashSet(); //avoid endless loops created by circular assignments for(var i=0;i<models.length;i++){ var oModel = models[i]; createModelGraphicRecursive(oModel, 0, "1") } dummyOutput.WriteReport() //otherwise it would overwrite the excel output! workbook.write(); function createModelGraphicRecursive(model, level, index) { if(setWrittenModels.contains(model.GUID())) return false; // already visited if(level>MAXLEVEL) return false; // too deep setWrittenModels.add( model.GUID() ) var sheet = workbook.createSheet(index +" "+model.Name(g_nLoc)); pictureOfModel(model,sheet); var oFuncDefs = model.ObjDefListFilter(Constants.OT_FUNC); var nFuncWithAssignment = 1; for (var k = 0; k < oFuncDefs.length; k++) { var oFuncDef = oFuncDefs[k]; var oAssignedModels = oFuncDef.AssignedModels(); for (var j = 0; j < oAssignedModels.length; j++) { var oAssModel = oAssignedModels[j]; if(createModelGraphicRecursive(oAssModel, level+1, index + "." + nFuncWithAssignment)) nFuncWithAssignment++; } } return true; } function pictureOfModel(oModel, sheet) { var pic = oModel.Graphic(false,false,g_nLoc); var sfileName = oModel.GUID() + ".png"; var width = pic.getWidth(Constants.SIZE_PIXEL ) * 20 * (100.0/125.0) //twips, correction factor because of excel anomaly (X): * (100.0/125.0) var xCells = width / 1024; var xTwips = width % 1024; var height = pic.getHeight(Constants.SIZE_PIXEL ) * 20*(100.0/133.0) //twips, correction factor because of excel anomaly (Y): \*(100.0/133.0)*/ var yCells = height / 256; var yTwips = height % 256; pic.setZoom(150) // image improvement only(optional) pic.Save(dummyOutput, sfileName); var data = Context.getFile(sfileName, Constants.LOCATION_OUTPUT); sheet.setPicture ( data, 0, 4, 0+xCells, 4+yCells, 0, 0, xTwips, yTwips); Context.deleteFile(sfileName); }
-
Hi All,
I know this may be a noob question but how can I do the same above but have the images display in a Word Doc instead?
Cheers
Sy
-
Hi Simon,
this is exactly what the standard report "Create process manual" does. You can start it on a process model (EPC, BPMN, Value Added Chain,...) and specify the level of assignments to consider.
BR, Torsten
-
I agree but my boss wanted to a report with only the models and nothing else, description/appendix etc etc , I have now gone through a copy of the Create Process Model and have done what they need. Was hoping to find a nice clean way of doing this code.
But thanks for getting back to me!! Really appreciate it