Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - BruceTOGAF2

Pages: [1] 2
1
Hi Geert

On the diagram properties there is
Diagram | Document Generation Options | Divide Diagram into multiple pages

I checked this checkbox to see what would happen. Diagram did divide over multiple pages.

Then I left this unchecked to see what would happen. I can only see a part of the diagram. To reveal the full diagram I have to (in MS-Word) manually shrink the diagram size to fit the page.

I am looking for a way of automatically (in Sparx) shrinking the diagram size to fit the page.

2
I am using docGenerator.DocumentDiagram( currentDiagram.DiagramID, 0, myRtfTemplateFragment) to "print" large diagrams in an RTF document.

Hi Geert,

I am not looking for dividing diagrams.  I am looking for a method to shrink each diagram so that it fits into the A4 age.

3
I am using docGenerator.DocumentDiagram( currentDiagram.DiagramID, 0, myRtfTemplateFragment) to "print" large diagrams in an RTF document.
After the RTF document has been built, I have to resize each diagram to fit neatly into an A4 page.

How can I force docGenerator to "print" those diagrams within the bounds of an A4 page?

In Tools, Options, Diagrams, Default Page Size is 'A4 Sheet, 210- by 297-millimeters'
In Tools, Options, Diagrams, Diagram Frames, there is a check box 'On printed Images'
In Tools, Options, Diagrams, General, there is a check Box 'Zoom to best scale'
In Tools, Options, Diagrams, I cannot find a check Box for 'Zoom to best scale' On printed Images

4
// The following lines open the Word document successfully
var wdObj = new ActiveXObject("Word.Application");
wdObj.Visible = true;
var wdDoc = wdObj.Documents.Open(inputFileName);

Thank you Geert

5
Does anyone know how to use Sparx Jscript to find all headings in a Word document?

// The following lines open the Word document successfully
var wdObj = new ActiveXObject("Word.Application");
wdObj.Visible = true;
var wdDoc = wdObj.Documents.Open(inputFileName);

      
// The following line prints Bookmarks.Count correctly
Session.Output("wdDoc.Bookmarks.Count:" + wdDoc.Bookmarks.Count);

// The following line prints Sections.Count correctly
Session.Output("wdDoc.Sections.Count:" + wdDoc.Sections.Count);
      
// Following line seems to be working because it takes a while in a large document
var myHeadings = wdDoc.GetCrossReferenceItems(wdRefTypeHeading);
      
// Following line shows blank
Session.Output("myHeadings" + myHeadings);
      
// Following line errors with "Object expected"
var lheadingCount = UBound(myHeadings) - LBound(myHeadings) + 1;
      
// Following line errors with "'Count' is null or not an object"
Session.Output("myHeadings.Count:" + myHeadings.Count);
      
// Following line errors with "'length' is null or not an object"
Session.Output("myHeadings.length" + myHeadings.length);

6
// The following code succesfully opens a CSV file as a worksheet
var xlApp = new ActiveXObject( "Excel.Application");
var xlBook = xlApp.Workbooks.Open (inputFileName);
var xlSheet = xlBook.Worksheets(worksheetNo);
var wsSource = xlSheet;
wsCell = wsSource.Cells(2, 1);

How do I do the same with a Word document?

// The following code fails to open a Word Document
var wordApp = new ActiveXObject( "Word.Application");
// Above line seems to succeed
var wordDoc = wordApp.Open (inputFileName);
// Above line errors out 'Object doesn't support this property or method'


// The following code fails to open a Word Document
var wordApp = new ActiveXObject( "Word.Application");
// Above line seems to succeed
var wordDoc = wordApp.Document.Open (inputFileName);
// Above line errors out 'Document is null or not an object'

7
I have found 'Automation Scripts' as an other export option under Project, Data Management, Export Reference Data.  Both problems (RTF Templates and Automation Scripts) solved.  Thank you.

8
Sorry Geert.  I could not see the <Group Name>.  Phil has suggested another method which I have used successfully today. In EA Version 12, Reference Data Import/Export can be found in Project, Data Management, Export Reference Data. I used Export Reference Data to export my RTF Templates. Then I successfully Imported RTF Template Reference Data  into my target .EAP.   However I could not see any option to export scripts as Reference Data.

9
I am trying to import RTF template Fragments and JScripts from source.EAP file into my target.EAP file.

In source.EAP I used Tools, Generate MDG Technology File.  In the MDG Technology Wizard I
•   included my Jscripts
•   included my RTF Template Fragments
•   saved the XML file to ‘my_path’.

In my target.EAP file I used Extensions, MDG Technologies, Advanced, Add, Add Path to point to ‘my_path’ containing the above-described XML file.

I am now able to see my JScripts (from the XML file) in the Scripting Window of my target.EAP file, but I cannot see my RTF Template Fragments in the Generate Documentation, Templates window.  I tried ‘Import Reference Data’, but that did not help.

Do you have any idea why I cannot see my RTF Template Fragments in the Generate Documentation, Templates window?

10
Hi Geert,

I am trying to replicate your code in Jscript.

The following code produces a runtime error: 'TextFile' is undefined.
var mappingFile = new TextFile;

The following code produces a runtime error: ';' expected.
var mappingFile as TextFile;

Any ideas?

11
My Jscript imports a CSV file with dates into Sparx EA and stores the dates in a tagged value. The CSV file holds each date in the format “dd/mm/yyyy” e.g. "14/09/2017" = 14th September 2017.

If the day is greater than 12, then the Sparx import stores the date correctly, e.g. "28/09/2017" = 28th September 2017.

If the day is greater than 12, then the API assumes format “dd/mm/yyyy”.

If the day is 12 or less, then the Sparx import stores the date incorrectly. The API assumes the date format is “mm/dd/yyyy”

If the day is 12 or less, then the Excel.Application API converts the first 2 numbers to the month e.g. "11/09/2017" = 9th November 2017 (should be 11th September 2017).

Here is some sample code to demonstrate the process.

// Open CSV file as a worksheet
var xlApp = new ActiveXObject( "Excel.Application");
var xlBook = xlApp.Workbooks.Open (inputFileName);
var xlSheet = xlBook.Worksheets(worksheetNo);
var wsSource = xlSheet   

var my11thDateCell = wsSource.Cells(11, 8);  // CSV Sample "11/09/2017"
var my12thDateCell = wsSource.Cells(12, 8); // CSV Sample "12/10/2017"
var my13thDateCell = wsSource.Cells(13, 8); // CSV Sample "13/09/2017"
var my14thDateCell = wsSource.Cells(14, 8); // CSV Sample "14/09/2017"

// A snippet from the tagged value update function which receives parameter last_Modified_Date
if (foundTag.Name == "08-Last_Modified_On") {
foundTag.Value = last_Modified_Date;
   myPTag7Found = true;
   foundTag.Update();

I have tried string conversions and parsing, but the problem still persists. Is there a more fundamental way of configuring the Sparx API to read the CSV dates as format “dd/mm/yyyy” ?

12
Automation Interface, Add-Ins and Tools / Re: currentPkg.Elements.Count
« on: November 09, 2017, 10:06:10 pm »
As usual Geert, your inspiration has helped me fix the problem.  The following function works well.

/*-------------------------------------------------------------
' Author:   Bruce Singleton
' Fixer: Geert Bellekens
' Date:     09/11/2017
         var theToPackage As EA.Package;
         theToPackage = taggedValueGetPkg("01-Absolute_Number", Absolute_Number, "heading");
'------------------------------------------------------------- */
function taggedValueGetPkg(property, value, versionVal)  {
   var soughtPkg as EA.Package;
   sql = "select obj.Object_ID AS OBJ_ID from t_objectproperties prop, t_object obj ";   
   sql = sql + "WHERE prop.Object_ID=obj.Object_ID ";
   sql = sql + "AND obj.Object_Type='Package' ";
   sql = sql + "AND prop.Property='" + property + "' ";
   sql = sql + "AND prop.Value='" + value + "'";
   s = Repository.SQLQuery(sql);

   var myIDs = xmlColumn( s, "OBJ_ID");
   for ( var i = 0 ; i < myIDs.length; i++ ) {
      var currentElement as EA.Element;
      currentElement = Repository.GetElementByID(myIDs);
      if (currentElement) {
         if (currentElement.Version == versionVal) {
            var soughtElement as EA.Element;
            soughtElement = currentElement;
            var soughtGUID = soughtElement.ElementGUID;
            soughtPkg = Repository.GetPackageByGUID(soughtGUID);
            return soughtPkg;
         }
      }
   }

   return soughtPkg;
}

Thank you.

13
Automation Interface, Add-Ins and Tools / Re: currentPkg.Elements.Count
« on: November 09, 2017, 09:47:42 pm »
Geert,

My initial post (currentPkg.Elements.Count) failed to explain the problem ‘currentPkg.Elements.Count’ properly.

I have a main Jscript that finds packages and processes the elements contained in each package.  My main Jscript finds the package using function taggedValueGetPkg() illustrated below.

Function taggedValueGetPkg looks for a particular tagged value ("01-Absolute_Number") and identifies the element containing the search Value in "01-Absolute_Number".

My main Jscript then tests the package contents, using currentPkg.Elements.Count, but reports 0 elements.

The problem is due to function taggedValueGetPkg which declares “var soughtElement as EA.Element”.

My main Jscript is finding each package as follows:

var paragPkg as EA.Package;
paragPkg = taggedValueGetPkg("01-Absolute_Number", Absolute_Number, "paragraph");

I know that function taggedValueGetPkg() works quite well because my main Jscript can test paragPkg.Name successfully.

Function taggedValueGetPkg() works quite well but it returns an Element object NOT a Package object.

SQL query 'select obj.Package_ID AS PKG_ID' will not work because that returns the package containing the package I am seeking.

How do I get function taggedValueGetPkg() to return the Package object associated with soughtElement?


/*-------------------------------------------------------------
' Author:   Bruce Singleton
' Date:     08/11/2017
'------------------------------------------------------------- */
function taggedValueGetPkg(property, value, versionVal)  {
   var soughtElement as EA.Element;
   // sql = "select obj.Package_ID AS PKG_ID from t_objectproperties prop, t_object obj ";
   sql = "select obj.Object_ID AS OBJ_ID from t_objectproperties prop, t_object obj ";   
   sql = sql + "WHERE prop.Object_ID=obj.Object_ID ";
   sql = sql + "AND obj.Object_Type='Package' ";
   sql = sql + "AND prop.Property='" + property + "' ";
   sql = sql + "AND prop.Value='" + value + "'";
   s = Repository.SQLQuery(sql);

   var myIDs = xmlColumn( s, "OBJ_ID");
   for ( var i = 0 ; i < myIDs.length; i++ ) {
      var currentElement as EA.Element;
      currentElement = Repository.GetElementByID(myIDs);
      if (currentElement) {
         // Session.Output("taggedValueGetPkg '" + currentElement.Name + "' " + currentElement.Version)
         if (currentElement.Version == versionVal) {
            soughtElement = currentElement;
            return soughtElement
         }
      }
   }

   return soughtElement;
}

14
Automation Interface, Add-Ins and Tools / currentPkg.Elements.Count
« on: November 09, 2017, 08:42:23 pm »
I have a package ‘Element Counter Test’ containing  5 elements. The following Jscript functions perfectly. It reports 5 (currentPkg.Elements.Count) elements

However I have another enormous Jscript that finds packages and processes the elements contained in each package.  It tests the package contents, using the same code as that shown below (currentPkg.Elements.Count), but reports 0 elements.

Any idea?

/* ========================================================================================
' Script Name: js_Element_Counter_Test
' Author: Bruce Singleton
' Purpose: Count elements in selected package
' Date: 07/11/2017
' ========================================================================================*/

 
function main()
{
       
       // Get the currently selected package in the Project Browser
       var currentPkg as EA.Package;
       currentPkg = Repository.GetTreeSelectedPackage();

       if (currentPkg)
       {
              Session.Output("Found package '" + currentPkg.Name + "' with " + currentPkg.Elements.Count + " elements");
       }
       else
       {
              Session.Output( "Package NOT selected.");
       }
       
}

15
Thank you to Dermot (Sparx Systems Support) for providing the specific solution to problem with ‘docGenerator & Diagrams with frame & diagram name in top left corner’.  I did the following:
- Opened the Generate Documentation dialog
- Unchecked the option "Hide Diagram Borders". 

The following Sparx Jscript code prints a diagram into docGenerator.NewDocument:
docGenerator.DocumentDiagram( currentDiagram.DiagramID, 0, "my_diagram_rtf_fragment");
The borders do now do appear in my RTF report. Excellent result!

Pages: [1] 2