Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Pawel Zubkiewicz on July 04, 2016, 05:55:58 pm
-
Hi all,
Once again, seeking your advise. I created simple script that creates number of elements and puts them on the diagram. Now I wonder whether it's possible to add LinkedDocument to one of those newly created elements. I have predefined template for LinkedDocument.
In API docs at http://sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/element2.html I see only 4 methods that operate with LinkdedDocuments.
- GetLinkedDocument() -If the element contains no linked document, an empty string is returned.
- LoadLinkedDocument(string Filename) - Notes: Loads the document from the specified file into the element's linked document
- SaveLinkedDocument(string Filename) -Notes: Saves the linked document for this element to the specified file. Returns False if the element does not have a Linked document or fails to save the file.
- DeleteLinkedDocument()
Looks like neither of them is useful for me right now.
Do you know any way to add linkeddocument to an element?
In theory, I could use LoadLinkedDocument and load docx from drive but it looks like very fragile solution... everyone would need to have the same file at the same location on his/her computer.
-
Can't you create a temporary file with the contents of you template and then use LoadLinkedDocument and pass the path to the temp file?
Geert
-
That's a great idea. Thanks Geert.
Already implemented, although I don't know how to delete this temporary file from drive. Is is possible?
-
Yes, why wouldn't that be possible?
Here's the (VBscript) code I use in my textfile wrapper (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/TextFile.vbs):
'delete the file
sub Delete
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(me.FullPath) then
fso.DeleteFile me.FullPath
end if
end sub
Geert