Problem with Exporting Diagrams

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Problem with Exporting Diagrams

Postby Raul Lorenzo » Fri Mar 10, 2006 7:12 pm

Hello,

I have the code I attached to export diagrams to JPEG per example, the
question is that the file doesn´t create.
Any Idea?
Thanks in advance

The output for that code is next:

Diagrama: Gestin Alumnos. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Alumnos"
Diagrama: Gestin Matriculas. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Matriculas"
Diagrama: Gestin Personas. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Personas"
Diagrama: Gestin Materiales. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Materiales"
Diagrama: Gestin Extraescolares. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Extraescolares"
Diagrama: Gestin Conceptos. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Conceptos"
Diagrama: Gestin Transporte Escolar. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Transporte Escolar"
Diagrama: Gestin Recibos. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Recibos"
Diagrama: Gestin Titulaciones. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Titulaciones"
Diagrama: Gestin de Profesiones. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin de Profesiones"
Diagrama: Gestin Cuentas Bancarias. Directorio: C: emp. Formato: 48
Exportando a "C: empGestin Cuentas Bancarias"
Diagrama: REM Model. Directorio: C: emp. Formato: 48
Exportando a "C: empREM Model"
Raul Lorenzo
 
Posts Rating:

Re: Problem with Exporting Diagrams

Postby Raul Lorenzo » Fri Mar 10, 2006 7:14 pm

Sorry, I forgot the code.
You do not have the required permissions to view the files attached to this post.
Raul Lorenzo
 
Posts Rating:

Re: Problem with Exporting Diagrams

Postby Tomas Pugzlys » Tue Mar 14, 2006 7:57 am

Hello,

ImageExporter.JPEG constant is equal to zero.
Formato: 48 indicates that incorrect format constant is passed.

Also jpeg file path should be more specific.

Here would be working example of all diagram export to JPEG:
Project project = Application.getInstance().getProject();
Collection diagrams = project.getDiagrams();
for (Iterator it = diagrams.iterator(); it.hasNext();)
{
DiagramPresentationElement dpe = (DiagramPresentationElement) it.next();
try
{
ImageExporter.export(dpe, ImageExporter.JPEG, new File("c:\temp",
dpe.getDiagram().getName() + ".jpg"));
}
catch (IOException e)
{
e.printStackTrace();
}
}

Adjust your code according to example.

Regards,
--
Tomas Pugzlys
Programmer
No Magic Lithuanian Development Center
Savanoriu pr. 363- IV, LT-49425, Kaunas
P.O. box 2166, LT-44011, Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
e-mail : tomasp
WWW: http://www.magicdraw.com
--
MagicDraw - UML Made Simple

nntp://news.nomagic.com/nomagic.products.magicdrawuml.openapi wrote:
> Sorry, I forgot the code.
>
>
> ------------------------------------------------------------------------
>
> public void Process_Export(File Directory,int diagramas,int formato_fichero,boolean save_to_REM,String origen,String user,String pass)
> {
> try
> {
> File fichero=null;
> String filename;
> String formato;
> formato=String.format("%d", formato_fichero);
> DiagramPresentationElement diagram=null;
> frame_plugin.setVisible(false);
> for(Iterator it=MD_project.getDiagrams().iterator();it.hasNext();)
> {
> diagram=(DiagramPresentationElement)it.next();
> filename=diagram.getName();
> Write_Log("Diagrama: "+filename+". Directorio: "+Directory+". Formato: "+formato);
> filename="""+Directory.getAbsolutePath()+"\"+filename+""";
> Write_Log("Exportando a "+filename);
> fichero=new File(filename);
> ImageExporter.export(diagram,formato_fichero,fichero);
>
> }
> .....
> .....
> ..
> ....
>

You do not have the required permissions to view the files attached to this post.
Tomas Pugzlys
 
Posts Rating:

Re: Problem with Exporting Diagrams

Postby Raul Lorenzo » Tue Mar 14, 2006 5:16 pm

Ok, Thanks for your help and support Tomas.

Tomas Pugzlys escribió:
> Hello,
>
> ImageExporter.JPEG constant is equal to zero.
> Formato: 48 indicates that incorrect format constant is passed.
>
> Also jpeg file path should be more specific.
>
> Here would be working example of all diagram export to JPEG:
> Project project = Application.getInstance().getProject();
> Collection diagrams = project.getDiagrams();
> for (Iterator it = diagrams.iterator(); it.hasNext();)
> {
> DiagramPresentationElement dpe = (DiagramPresentationElement)
> it.next();
> try
> {
> ImageExporter.export(dpe, ImageExporter.JPEG, new
> File("c:\temp", dpe.getDiagram().getName() + ".jpg"));
> }
> catch (IOException e)
> {
> e.printStackTrace();
> }
> }
>
> Adjust your code according to example.
>
> Regards,
You do not have the required permissions to view the files attached to this post.
Raul Lorenzo
 
Posts Rating:


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 4 guests