Book a Demo

Author Topic: Creating a linked document by script/addin  (Read 5806 times)

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Creating a linked document by script/addin
« on: September 21, 2011, 03:55:07 pm »
Hi,

is it possible ( and how is it possible) to create and write into an linked document from a script or an Addin?

i want to fetch some things from outside enterprise architect which is a text document or text part and want to write it into an linked document.

Is this possible?

i startet to create a normal element with an linked document in EA and have written the needed text into the "binContent" but couldn't find the correct formatting to make the binary content backwards readable for EA. does someone allready have such a sql.execute line allready?

any idea's or solutions for this matter?

thank you
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Creating a linked document by script/addin
« Reply #1 on: September 21, 2011, 03:58:25 pm »
See methods GetLinkedDocument, LoadLinkedDocument, and SaveLinkedDocument on the EA.Element class.
http://www.sparxsystems.com/enterprise_architect_user_guide/9.0/automation/element2.html

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: Creating a linked document by script/addin
« Reply #2 on: September 21, 2011, 04:59:48 pm »
yes, that is right, but -

maybe i misinterpret:

getlinked.... fetch the linked document content into a string
loadlinked....load an external document from harddisc into an document
savelinked....save the linked document into a file on the harddisc

when i have my text allready as string? how can i put it into linkeddocument?

save into c:\temp and than load it back?
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Creating a linked document by script/addin
« Reply #3 on: September 21, 2011, 07:12:24 pm »
Just had a look in my scripts and that's exactly what I do. The script is quite old, so there might have been new methods introduced in the meantime.

q.

skrauss

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Creating a linked document by script/addin
« Reply #4 on: September 23, 2011, 07:30:04 pm »
I would recommend to use the Generator Class.

Here an idea for implementation:
1. Create a Document Generator object
2. Add the text needed with gendoc.AddText "<Text>", "<Style>"
3.  Save the document temporarly as RTF with gendoc.SaveDocument rtf_filename, 0 ' 0 = RTF, 1=HTML
4. Import the generated document with element.LoadLinkedDocument

Dim gendoc as EA.DocumentGenerator
Set gendoc = Repository.CreateDocumentGenerator()
gendoc.NewDocument("<your Template name here>")
gendoc.AddText("<Add your text, whereever it comes from>" & vbCrLf, "Heading 1")
...
gendoc.SaveDocument "C:\tmp\tmp.rtf", 0 ' 0 = RTF, 1=HTML
element.LoadLinkedDocument("C:\tmp\tmp.rtf")


If you create a template with the needed formattig, you can specify it with InsertText. For example if you add "Strong" the text will be bold in the standard template.

Sven