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 3
1
Automation Interface, Add-Ins and Tools / Re: Repository.Models.Refresh()
« on: January 12, 2018, 11:43:44 pm »
Thank you Geert.  I am very pleased with this development and with your help, so I will post the complete Jscript code in a new topic.

Import Word document into Sparx nested packages

Good idea?

2
Automation Interface, Add-Ins and Tools / Re: Repository.Models.Refresh()
« on: January 12, 2018, 09:37:39 pm »
Hi Geert,

I also tried Repository.RefreshModelView()

I got error "Argument not optional"

3
Automation Interface, Add-Ins and Tools / Repository.Models.Refresh()
« on: January 12, 2018, 08:57:30 pm »
I have seen comments on this forum like "Repository.Models.Refresh() doesn't work".  In my experience it did work an other scripts but not in my current Jscript project.

My Jscript imports a word document into Sparx packages and Artifacts.  Each time I create a new package, I update the Package.TreePos with an incremental counter so that packages are sequenced correctly.  After the MS-Word document has been imported, I execute Repository.Models.Refresh(), but it is seemingly being ignored. Nothing changes.

If I close the Sparx project and re-open the project file, only then I can see the packages in the correct sequence as per Package.TreePos.

Why is Repository.Models.Refresh() failing?

4
I tried a recommendation from Colin Coates, a fellow member of LinkedIn Group 'Enterprise Architect (Sparx Systems) User Group'

I tried right-clicking each diagram and then setting the radio-button you see by clicking through Properties|Diagram|Advanced|Scale to 1 Page?

This has made no difference.

I fail to see how switching to Virtual Documents would make any difference.

Looks like a bug in Sparx EA 12.

5
My Jscript identifies the level of each package in a package hierarchy. My Jscript reports the name of the package, specifying which RTF Template Fragment (e.g. 'logfs_head_level_1') to use according to hierarchy level.

var pkgRtfTemplate = pkgNameRtfTemplate(level);
docGenerator.DocumentPackage( parentPackage.PackageID, 0, pkgRtfTemplate);

The following text demonstrates the heading level error in my RTF export from Sparx.

1  I am Heading Level 1. I am functioning correctly
2  I am Heading Level 1. I am functioning correctly
3  I am Heading Level 1. I am functioning correctly
   3.1  I am Heading Level 2. I am functioning correctly
   3.2  I am Heading Level 2. I am functioning correctly
      3.2.1  I am Heading Level 3. I am functioning correctly      
         3.2.1.1  I am Heading Level 4. I am functioning correctly
         3.2.1.2  I am Heading Level 4. I am functioning correctly         
            3.1.1.1.37  I am Heading Level 5. I am malfunctioning
            3.1.1.1.38  I am Heading Level 5. I am malfunctioning


My RTF Template Fragments 'logfs_head_level_1', 'logfs_head_level_2' etc print the package name within a heading style.
Heading Levels 1 to 4 use RTF Template Fragments that contain styles available in the drop-down list of the RTF Template editor.
For example, Heading Level 4 uses 'heading 4, H4,h4, ...' from the drop-down list of the RTF Template editor.

The problem starts when I use my RTF Template Fragment 'logfs_head_level_5' that I have created to report Heading Level 5. 
The drop-down list of the RTF Template editor does not offer 'heading 5, H5, ...'.
I copied a Heading Level 5 from a Word document and pasted it into my RTF Template Fragment that I have created to report Heading Level 5.
The result is 5 parts to the heading (e.g. 3.1.1.1.38), but the parent heading number is ignored.

There are multiple sets of heading styles in the drop-down list of the RTF Template editor.

I then amended RTF Template Fragment 'logfs_head_level_5' to style 'Heading 5' within "Heading 1, Heading 2, Heading 3, Heading 4, Heading 5, etc".
The result is still 5 parts to the heading (e.g. 3.1.1.1.38), but the parent heading number is still being ignored.

Instead of using "heading 1, H1,h1, ...,heading 2, H2,h2, ...,heading 3, H3,h3, ...", I tried using "Heading 1, Heading 2, etc" for all Fragments 'logfs_head_level_1', 'logfs_head_level_2' etc.

The problem with this approach is that styles "Heading 1, Heading 2, etc" do not print the heading numerical prefix.

How can I edit styles "Heading 1, Heading 2, etc" so that they print the heading numerical prefix?


6
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.

7
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.

8
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

9
// 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

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

11
// 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'

12
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.

13
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.

14
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?

15
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?

Pages: [1] 2 3