Hi,
I have got a request to export EPC as a graphic file like JPEG or some other common format. However, it seems ARIS Script only supports doc/pdf/xls/rtf/txt/html format. I noticed that when exporting EPC as html, a png file would be created. Does any one know how to get the png file directly using ARIS script?
Thanks in advance.
Regards,
Will
Hi Will,
First, you need to specify which model should be exported. This is done as follows:
var models = ArisData.getSelectedModels()
Then you need the method “createOutputObejct()”, which returns a new output object with preset name, format, and media size .
var outputDummy = Context.createOutputObject()
Getting the graphic of a model can be done by calling the Graphic method of the model object. This method uses three parameters. The first parameter means that the object is always visible on a part of the graphic. The second parameter defines whether 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 picture = models[i].Graphic(false, false, Context.getSelectedLanguage()
The method“Save()” saves a picture object as an EMF, PNG, or JPG file. In our example the picture is saved as a png
picture.Save(outputDummy, imageFileName)
Everything else is just iterating over the list of models, etc..
var models = ArisData.getSelectedModels() var outputDummy = Context.createOutputObject() for(var i=0; i<models.length; i++) { var picture = models[i].Graphic(false, false, Context.getSelectedLanguage() ) var imageFileName = "ModelImage_"+i+1+".png" picture.Save(outputDummy, imageFileName) Context.addOutputFileName(imageFileName) Context.setSelectedFile(imageFileName) }
Make sure to watch the Reports & Macros group. There you will find additional tutorials which will help you to get started with ARIS scripting.
Regards
Eva
Hello!
I used following code in ARIS 7.2 script and it worked fine.
var output = Context.createOutputObject(); var picture = model.Graphic(false, false, Context.getSelectedLanguage()); var imageFileName = model.Name(g_nLoc)+".png"; picture.Save(output, imageFileName);
Now I am trying to run the same script in ARIS 9.6 and I am getting an error on calling ‘Save’ function:
Can't find method com.idsscheer.report.output.external.interfaces.impl.APicture.Save(com.idsscheer.report.output.outputobject.asposeapi.AMergeableOutputObject,string)
Does anyone know where could be the problem by running the script in ARIS 9.6?
Thanks
Matus
Good morning! Please Help me
I run script:
var aModel = ArisData.getSelectedModels();
var oOutput = Context.createOutputObject();
var nLoc = Context.getSelectedLanguage();
for(var i = 0; i <aModel.length; i ++){
var picture = aModel[i].Graphic(false, false, nLoc);
var imageFileName = " " + i + 1 + ". png";
picture.Save (oOutput, imageFileName);
Context.addOutputFileName (ImageFileName);
Context.setSelectedFile (ImageFileName);
}
but out error: Unable to greate the model Graphic.
Why?????
Three things to note here:
- There is a space in between your dot and file extension type in your imageFileName variable value. That's what makes the picture.Save(...) method crash.
- You should remove either the line with Context.addOutputFileName(...) or the line with Context.setSelectedFile(...), they do almost the same thing and you need only one of them. Which one you choose depends on what you want to do. Is there a normal output file, like a .doc file and you want the .png in addition to that .doc file, use Context.addOutputFile(...). If the .png file is the only file you want, use Context.setSelectedFile(...)
- In whichever line remains from my second note, you should change " ImageFileName" to " "imageFileName".
I apologize for any confusion I may have caused. The simplest working way I could find was the following:
var aModel = ArisData.getSelectedModels(); var oOutput = Context.createOutputObject(); var nLoc = Context.getSelectedLanguage(); for(var i = 0; i <aModel.length; i ++){ var picture = aModel[i].Graphic(false, false, nLoc); var imageFileName = " " + i + 1 + ".png"; picture.Save (oOutput, imageFileName); Context.addOutputFileName (imageFileName); }
Hello Eva,
I have a question that the Save option might be the answer for,
I am trying to reduce the size of a report that I created. The report summarize some (a lot) models into a word document.
The problem that we encountered was that the file created as RTF and because of this exceeds the 512 MB size allowed (by Microsoft).
I tried to lower the resolution of the pictures and transfer them to black and white, but it only partly helped (the file is smaller but still above the 512 MB).
Is there any chance that the save function could help me reduce the pictures resolution inside the RTF document?
Thank you very much in advance,
Gilad
Hi Gilad,
Which ARIS version do you use? If it's the latest 7.2, you could try a new feature which will become 'official' soon. If you use output format MS Word ("doc"), not RTF(!), calling the following line of code before creating an output object in your script, will use a new implementation of the output object, which creates much smaller DOC output files:
Context.setProperty("use-new-output", true)
Best regards,
Torsten
Hi Torsten,
Thank you very much for the replay,
I am using the 7.2 and I even tried to use the Context.setProperty("use-new-output", true).
The problem with that, beside the very good outcome of a smaller size document, it "destroyed" my index and "demolished" my in-text hyperlinks.
Did you ever tried using those 2 (index + hyperlink) with the new feature?
Thank you once again,
Gilad
Hi Torsten,
I am ataching the relevant parts from my code,
any help will be highly appreciated,
Thanks again,
Gilad
Code regarding TOC
Constants.C_BLACK, Constants.C_TRANSPARENT,Constants.FMT_BOLD| Constants.FMT_LEFT, 0, 0, 0, 0); g_ooutfile.SetTOCFormat(1, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD| Constants.FMT_LEFT ,1, 1, 0, 0); g_ooutfile.SetTOCFormat(2, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT ,2, 2, 0, 0); g_ooutfile.SetTOCFormat(3, "Arial", 9, Constants.C_BLACK, Constants.C_TRANSPARENT,Constants.FMT_BOLD| Constants.FMT_LEFT ,3,10, 0, 0); var firstLevel = "HEADING 1" var secondLevel = "HEADING 2" var thirdLevel = "HEADING 3" var fourthLevel = "HEADING 4" Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD|Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_TOCENTRY0, 0, 0, 0, 0, 0, 1); g_ooutfile.DefineF(secondLevel, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD| Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_TOCENTRY1 , 4, 0, 0, 0, 0, 1); g_ooutfile.DefineF(thirdLevel, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_TOCENTRY2 , 8, 0, 0, 0, 0, 1); g_ooutfile.DefineF(fourthLevel, "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD| Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_TOCENTRY3, 12, 0, 0, 0, 0, 1); function outputTOC( ){ g_ooutfile.BeginSection(true, Constants.SECTION_INDEX); g_ooutfile.OutputLnF("Table Of Contents", "Ariel18BoldCenter" ); g_ooutfile.OutputLnF("","Ariel18BoldCenter" ); g_ooutfile.SetAutoTOCNumbering(true) g_ooutfile.BeginParagraph(Constants.FMT_LEFT, 5, 5, 5, 5, 0, 2, 10); g_ooutfile.OutputField( Constants.FIELD_TOC, "Arial", 10,Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT); g_ooutfile.EndParagraph(); //g_ooutfile.EndParagraph(); g_ooutfile.EndSection(); }//END::outputTOC() g_ooutfile.OutputLnF("Executive Summary", firstLevel);
Code regarding Hyperlink -
Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD| Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_LINKTARGET | Constants.FMT_TOCENTRY1, 4, 0, 0, 0, 0, 1); g_ooutfile.DefineF("insteadOfHeading2", "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_BOLD| Constants.FMT_LEFT| Constants.FMT_VTOP | Constants.FMT_LINKTARGET | Constants.FMT_TOCENTRY2, 8, 0, 0, 0, 0, 1); g_ooutfile.OutputLinkF(ScreenViewAppName,ScreenViewAppName,"Ariel10LeftLink"); g_ooutfile.OutputLnF(ScreenViewAppName, "insteadOfHeading"); "