Profile picture for user Eva Klein

Today, I want to show you how easy it is to export the image of an ARIS model using a small ARIS Report. The simple report exports the images of the selected models into a MS Excel sheet.

First, we need to know which model should be exported. This is done as follows:

var models = ArisData.getSelectedModels();

We can create a new MS Excel workbook by calling the method “createExcelWorkbook”. The parameter specifies the file to be created.

var workbook = Context.createExcelWorkbook(Context.getSelectedFile());

To create a sheet for every selected model you have to call the method “createSheet”. The parameter specifies the name of the new sheet. Below, I use the name of the model as the name of the new sheet.

var sheet = workbook.createSheet(oModel.Name(g_nLoc));    

Getting the graphic of a model can be done by calling the Graphic method of the model object. This method takes three parameters. The first parameter means the object is always visible on a part of the graphic. The second parameter defines if the returned graphic should be black & white or contain colors (false = color, true = black and white). The last parameter specifies the language to be returned.

var pic = oModel.Graphic(false,false,g_nLoc);

To get the width and height of the graphic, we use the methods “getWidth” and “getHeight”.

var width = pic.getWidth(Constants.SIZE_PIXEL ) * 20 * (100.0/125.0)
var height = pic.getHeight(Constants.SIZE_PIXEL ) * 20 * 20*(100.0/133.0)

To add the model graphic to the MS Excel table, we have to call the method “setPicture”. The parameters describe the picture to be added and the cells and rows where the picture starts and ends.

sheet.setPicture (data, 0, 4, 0+xCells, 4+yCells, 0, 0, xTwips, yTwips);

Those are the most important commands used in the script. Everything else is just iterating over the list of models, etc. 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);
    }
}

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

Here you can download the entire source code from the "Output picture of model" report.

Note: Make sure to join the Reports & Macros group. You will find additional tutorials and a list of free ARIS reports and macros.

by Mia van Rooyen
Posted on Tue, 12/07/2010 - 09:14

Hey Eva,

How can one highlight the path in a model?

Thanks,

Mia

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Tue, 12/07/2010 - 09:27

Hi Mia,

I'm not sure if I understand you correctly. What do you mean with path, the connections between functions? Could you give me an example, please.

Regards

Eva

0
by Mia van Rooyen
Posted on Tue, 12/07/2010 - 10:31

I have to draw a rectangle around the function in the model graphic as per SAP->General Test Case Documentation Script. 

Thanks in advance,

Mia

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Wed, 12/08/2010 - 15:16

If you copy this function into the script you should be able to achieve the required result. When calling the function in the script, the ObjOcc and color information must be included.

function drawrectangle(oobjocc, ncolor) {

    var aPoints = new Array();
    aPoints.push(new java.awt.Point(oobjocc.X() - 5, oobjocc.Y() - 5));    
    aPoints.push(new java.awt.Point(oobjocc.X() + oobjocc.Width() + 5, oobjocc.Y() - 5));    
    aPoints.push(new java.awt.Point(oobjocc.X() + oobjocc.Width() + 5, oobjocc.Y() + oobjocc.Height() + 5));    
    aPoints.push(new java.awt.Point(oobjocc.X() - 5, oobjocc.Y() + oobjocc.Height() + 5));    
    aPoints.push(new java.awt.Point(oobjocc.X() - 5, oobjocc.Y() - 5));        

    var oPolygon = oobjocc.Model().createPolygon(aPoints, false);
    oPolygon.setPenStyle(Constants.PS_SOLID);
    oPolygon.setPenColor(ncolor);    
    oPolygon.setPenWidth(5); 
    oPolygon.setZOrder((oobjocc.getZOrder() - 1));   

    return oPolygon;
}

I hope this information is useful for you.

Regards

Eva

0
by Sebouh Havatian
Posted on Thu, 12/09/2010 - 10:58

Hi

Is there a way to output the graphic of an object instead of the entire model?

Thanks

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Thu, 12/09/2010 - 15:08

Hi Sebouh,

Unfortunately this does not work.  You can try the following: create a new model via report, insert the object into the model, export the graphic and then delete the model.

Regards

Eva

0
by Ciska de Jager
Posted on Fri, 12/17/2010 - 17:52

Hi Eva,

Thank you for all your valuable inputs, maybe you can help me with how to delete graphical objects from a model, for example Polygons. As they are not occurrences the deleteocc command doesn't work, is there any other way, to delete them using script and not a macro.

Ciska

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Mon, 12/20/2010 - 08:58

Hi Ciska,

there is a special method in the model which removes the graphic object.

deleteGfxObj ( GfxObj p_gfxToBeDeleted )

I hope this helps you.

Regards

Eva

0
by Ciska de Jager
Posted on Mon, 12/20/2010 - 12:32

Hi Eva,

Thank you, I will give this a try later on, I believe this will help a lot.

Ciska

0
by jay olvey
Posted on Wed, 05/25/2011 - 23:47

Eva - any way we could have this as a .arx?

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Thu, 05/26/2011 - 08:02

Here you can download the entire source code from the "Output picture of model" report as .arx file.

0
by jay olvey
Posted on Thu, 05/26/2011 - 17:19

Hi Eva - when I try this, I get an error in line 43?

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Fri, 05/27/2011 - 07:59

Hi Jay - what error message do you get?

0
by jay olvey
Posted on Fri, 05/27/2011 - 18:38

Eva - interestingly, I am no longer receiving an error.  hmm.  must be 'user error'  :)

0
by Ignacio Arriagada
Posted on Fri, 08/05/2011 - 15:27

I'm trying to insert a rectangle in a ModelPicture, with the Picture.Rectangle() method.

In theory, the Picture methods are available for a ModelPicture object. Then, i can use getWidth(), getHeight(), etc., but when using Rectangle(), SelectBrush(), SelectPen(), etc. i get a Wrapped java.lang.NullPointerException.

Can i use these functions that "write" on the picture or have to find other solution? I'm using ARIS 7.1 SR 2010_09

0
by ravi kiran
Posted on Thu, 08/11/2011 - 11:50

hi eva

this is very helpful for me thnks.How to add some text under hedding could u help me

 

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Thu, 08/11/2011 - 13:48

Hi Ravi,

why do you want to add text below a heading if there is no text in the report?

0
by Julien Job
Posted on Wed, 10/19/2011 - 12:36

Hi,

for of all, thanks for this script.

I have just one question :

How adapt this script for generation one Excel for each model of my BDD ?

 

Thank you in advance

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Wed, 10/19/2011 - 12:52

Hi Julien,

to make sure that I understand you correctly: do you want to have a separate Excel output for each model? Another question: what do you mean by BDD?

0
by Julien Job
Posted on Wed, 10/19/2011 - 14:16

You understand me correctly ! :)

BDD = DataBase (.adb)

I have several models in my adb and i would like one file for each model

 

Thanks

0
by Julien Job
Posted on Wed, 10/19/2011 - 14:36

Otherwise, I have each GUID of model but how create oModel object with GUID ?

0
by Julien Job
Posted on Wed, 10/19/2011 - 15:42

With oModel, Can I recover GUID ?



Exemple :

 guid =  oModel.getGUIDAsString();



I have an error with this line :



Cannot find function getGUIDAsString in object Model@270 ...



Why ?

 

edit :

guid =  oModel.GUID;  It okey

0
by Julien Job
Posted on Wed, 10/19/2011 - 15:43

My Script :

var workbook;
var sheet;
var g_nLoc = Context.getSelectedLanguage();
var models = ArisData.getSelectedModels();
//guid =  ArisData.getActiveDatabase().getSelectedModels());
var dummyOutput = Context.createOutputObject();
var guid = "_Blank";

main();

dummyOutput.WriteReport() //otherwise it would overwrite the excel output!


function main(){
    for(var i=0;i<models.length;i++){
        var oModel = models[i];
       guid = oModel.GUID();
        
        //Creation fichier Excel
        workbook = Context.createExcelWorkbook("m" + guid + "_gfx.xls");
        
        sheet = workbook.createSheet(oModel.Name(g_nLoc));    
        pictureOfModel(oModel,sheet);
        
        workbook.write();
    }
}

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);
0
by Brooke Baker
Posted on Sun, 11/06/2011 - 09:41

Hi,

I realise this thread is old, but is there anyway to create the picture in the current worksheet rather than creating a new sheet? I have already output a table of data and want the graphic beneath.

Thanks

 

0
by Torsten Haase
Posted on Mon, 11/07/2011 - 11:39

Hi,

this should be possible. Just replace the

sheet = workbook.createSheet(...)

by

sheet = workbook.getSheetAt(your sheet's index)

and adjust the column and row in line 42 (sheet.setPicture(imagedata, column, row,...) )

 

0
by Frank Beyer
Posted on Wed, 08/08/2012 - 10:05

Hi Eva,

thanks for your report, we are using it since 1 year. Now we have updated our ARIS to 7.2 and the files produced by the report are bigger (two times as big as before). Is there a version 7.2 of this report or is it normal?

Thanks in advance and kind regards,

Frank

0
by Eva Klein
Badge for 'Community Team' achievement
Author
Posted on Wed, 08/08/2012 - 14:54

Hi Frank,

It is possible that the size of the graphics the Designer component provides has increased with version 7.2.

Regards

Eva

0
by Alikhan Dan
Posted on Fri, 04/12/2013 - 14:47

Hi Eva!

I wonder if you could help me to solve some problem. Above you provided a great scrip for the report using pictures. But I would like to ask you if you could further the report.

Is it posible to export every models from different diagrams form ARIS I've drawn to excel file as pictures, with all their relations? So I can go through the entire chain because I can see not only the individual models on different sheets (as it is on you example report) but also relationships between them (links).

Thank you very much!

All the best.

 

 

0
by Sandeep Nikwade
Posted on Mon, 08/26/2013 - 10:36

Hi Eva

I’m new to this group and read all your reporting related articles and did the implementation of some report on my ARIS 7.1, some of run fantastic and some gave the error which is not yet solve ( will see those later) but I need help on report / script which are  -

  • To extract a map image (in JPEG  / JPG format) in excel with separate sheet for each process map, if I run that report on process folder which is contain ‘N’ number of maps.
  • A excel sheet containing the list of map with its vertical linkage, the background is we follow the vertical flow from level 1 to level 4 (Level 1 is SIPOC, Level 2 is EPC row display, level 3 is VACD and level 4 is EPC) and they are connected to each other. So I want a report which shows the list of level 4 which is under each level 3, list of level 3 which is under level 2 and so on once I click the home or process folder. So basically report look like below way..

Level 1   |     level 2     |     level 3     |        Level 4      |        other few details|||||

Is that possible through script or through WYSIWYG Editor?? if through WYSIWYG editor then how? 

  • Other report/template for object placement & flow, the basic background is that we map the EPC process in horizontal way because our default template and filter and customer wanted (to convert) those in to vertical way, how we can do that with help of report or any readymade template, is that possible? Because we have ARIS portal where we have option to view the map in vertical but not in the ARIS architect database.

Very appreciate if you can provide some help or clue on above issue / requirements.

BR

Sandy.

0
by Med Baklawa
Posted on Wed, 02/06/2019 - 15:19

Hi everybody,

I have also a problem while creating a graphic as an excel. 

The strang is that the Script works but not every time... Specially when I try to run many modells at the same time, it came this error (see pic.)

I would be thankful, if someone could help. 

This is my script:

 

var C_MAGIC_TWIPS_PER_CHARACTER = 120; //115.90909090909;

var C_MAGIC_TWIPS_PER_PIXEL = 5.0;

var g_oExcel = null; 

function main() {

    

    g_oIHelper.INIT_BuildLanguageList();

    

    var omodellist = ArisData.sort(ArisData.getSelectedModels(), Constants.AT_NAME, Constants.SORT_NONE, Constants.SORT_NONE, g_nLoc[0]);

    

    if (omodellist.length == 0) {

        Dialogs.MsgBox("Please start the report on at least 1 model!", Constants.MSGBOX_ICON_ERROR, null);

        return;

    }

    

    if (omodellist.length > 99) {

        Dialogs.MsgBox("Please start the report on a maximum of 99 models!", vbCritical);

        return;

    }

    

    // Initialize Excel file based on C Standards

    //  20180620_RS Excel output fix

    // OLD: g_oOutfile_2 = Context.createExcelWorkbook(Context.getSelectedFile());

    g_oOutfile_2 = Context.createExcelWorkbook("report.xlsx");

    

    for(var i = 0; i < omodellist.length; i++){

        Context.writeStatus("Working on model no. " + (i + 1) + " / " + omodellist.length)

        createmodelxls(omodellist[i]);

    }    

    g_Sheet_2.write();

}

function createmodelxls(oModel) {

    g_Sheet_2 = g_oOutfile_2.createSheet(oModel.Name(g_nLoc[0]));    

    g_Sheet_2.setFitToPage(true);

    

    var pic = oModel.Graphic(false,false,g_nLoc[0], true);

    pic.setZoom(150); // image improvement only(optional)

    

    var g_oOutfile = Context.createOutputObject(Constants.OUTEXCEL, "test.xls");

    pic.Save(g_oOutfile, "p1.png");

    var firstBytes = Context.getFile("p1.png", Constants.LOCATION_OUTPUT);    

    var firstDims = calculateImageToExcel(pic, g_Sheet_2);

    g_Sheet_2.setPicture(firstBytes, 0,1,1+firstDims.widthcells,2+firstDims.heightcells, 10, 10, firstDims.widthaddtwips, firstDims.heightaddtwips);

}

main();

 

File attachments
0
by Torsten Haase
Posted on Wed, 02/06/2019 - 15:36

Hi Med,

what does your log say? (abs log: internalerr.log, jsreport.log, ).

Additionally:

Maybe the new image insertion methods of xlsSheet are worth a try, because their handling is much easier:

sheet.insertCellPicture(int column, int row, byte[] imageData, int imageFormat, double widthMM, double heightMM)

sheet.insertPicture(int column, int row, byte[] imageData, int imageFormat, int insertMethod, double widthMM, double heightMM)

BR, Torsten
0
by Med Baklawa
Posted on Wed, 02/06/2019 - 16:55

In reply to by thaase

Thanks for replaying. I tried with the insert.Pic Method, but unfortunately  still the same problem.

Sorry but I don´t know how to access to the log. Could you please help me ?

Thank you.

0
by Med Baklawa
Posted on Thu, 02/07/2019 - 12:40

Dear Clark, 

thank you for the information.

And does the SOFTWARE AG respond ?

Do you know, when this problem probably will be solved ?

BR 

Baklawa  

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock