Book a Demo

Author Topic: Save Linked Document to File  (Read 6256 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Save Linked Document to File
« on: December 15, 2011, 08:53:12 am »
Hi all,


OK, maybe I'm just being stupid here, but -

I've never had much use for Linked documents before, preferring to keep any generated documents in an external version-control repository.

But now I'm playing around with the create-document-to-artifact feature (new in 9.2), and I'm loving it. Only thing is, I'd like to do both: keep the most recently generated document in EA, and track it in my version-control repository.

So is there a way of dumping a Linked Document to a file?

Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Save Linked Document to File
« Reply #1 on: December 15, 2011, 05:15:29 pm »
Uffe,

IIRC the linked documents are stored as a zipped rtf blob in the database.
So I guess if you unzip the contents, and write that to a file it should yield a usable .rtf file.

Geert

Shaggy Man

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Save Linked Document to File
« Reply #2 on: December 15, 2011, 05:26:53 pm »
Is help you following EA API?

Element.SaveLinkedDocument()
Element.GetLinkedDocument()

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Save Linked Document to File
« Reply #3 on: December 15, 2011, 05:35:56 pm »
I guess we should always first RTFM :-[

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Save Linked Document to File
« Reply #4 on: December 15, 2011, 07:53:26 pm »
Erhm, yes...  :-[  :-[

But I did primarily mean from the GUI, and the concensus on that seems to be no.
So a script to the rescue. To make up for my laziness in not RTFMing, here's a snippet that's intended to be pasted into a Diagram script.

Enjoy!

/Uffe

Code: [Select]
if not selectedConnector is nothing then
    ' A connector is selected
    Session.Prompt "This script requires a single «document» Artifact to be selected", promptOK
elseif selectedObjects.Count <> 1 then
    ' Multiple diagram objects are selected
    Session.Prompt "This script requires a single «document» Artifact to be selected", promptOK
else
    ' A single diagram object is selected
    dim selectedElement as EA.Element
    set selectedElement = Repository.GetElementByID(selectedObjects.GetAt(0).ElementID)
    if (selectedElement.Type <> "Artifact" or selectedElement.Stereotype <> "document") then
        Session.Prompt "This script requires a single «document» Artifact to be selected", promptOK
    else
        dim fileName, fileDialog, dialogResult
        set fileDialog = CreateObject("UserAccounts.CommonDialog")
        fileDialog.Filter = "RTF Files|*.rtf|All Files|*.*"
        fileDialog.FilterIndex = 1
        if fileDialog.ShowOpen then
            selectedElement.SaveLinkedDocument(fileDialog.fileName)
        end if
    end if
end if
My theories are always correct, just apply them to the right reality.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Save Linked Document to File
« Reply #5 on: December 16, 2011, 08:17:22 am »
From the GUI is easy too.

Open the document.
Right click
File | Export.