Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: ja1234 on January 05, 2017, 01:48:43 am
-
This code does NOT >:( work:
var prj = Repository.GetProjectInterface();
prj.RunReport("{GUID}", "test","C:\\diagram_export\\3.rtf");
where test is a template in User Templates
I simply have hardcoded something in the "test" file and I want to export it into a rtf. Ideas why it is not working?
-
At a guess: the GUID must be formatted with prj.GUIDtoXML (guid)
q.
-
var prj = Repository.GetProjectInterface();
var id = Repository.ProjectGUID;
var xmlID = prj.GUIDtoXML(id);
prj.RunReport(xmlID , "test","C:\\diagram_export\\3.rtf");
Thanks. Tried it, still not working. Everything that I put as arguments is simply ignored - the document generation window triggers with a totally different template name and path. :o :o :o
-
It helps if you read the explanation in the manual.
Simply guessing and throwing random stuff at the operations usually doesn't work.
http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html
(http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html)
Geert
-
It helps if you read the explanation in the manual.
Simply guessing and throwing random stuff at the operations usually doesn't work.
http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html
(http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html)
Geert
Probabilistic programming and it can sometimes work , especially when the documentation is ambigous ;)
so, here's the deal:
- assume a package, that does not have the stereotype MasterDocument
- you want to RunReport on that package, from a script
Select the package in the Project Browser Window
then in your script add:
var currentProject = Repository.GetProjectInterface; //gets current project
var id = currentSelectedElement.PackageGUID; //gets currently selected package GUID
currentProject.RunReport(id, "Your_Custom_Template_Name", "C:\\exports\\1.rtf");
where Your_Custom_Template_Name is saved in Resources/User Templates
This works.
-
I'm sorry, from your response I can't make out if you have solved the issue or still have a problem and you are requesting help.
Geert
-
I just tried the above snippet and had no issue creating a report.
q.
-
Yes the snippet works, putting it out there for anyone who might have the same problem.