Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Thomas Arnbjerg on March 27, 2024, 07:30:36 pm

Title: Model documents and scripts
Post by: Thomas Arnbjerg on March 27, 2024, 07:30:36 pm
Is there a way to modify the packages in a model document from a script?
Title: Re: Model documents and scripts
Post by: Geert Bellekens on March 27, 2024, 10:22:31 pm
Yes, sure, they are attributes.

Code: [Select]
function addModelDocumentForPackage(masterDocument,package,name, treepos, template)
dim modelDocElement as EA.Element
set modelDocElement = masterDocument.Elements.AddNew(name, "Class")
'set the position
modelDocElement.TreePos = treepos
modelDocElement.StereotypeEx = "EAUML::model document"
modelDocElement.Update
'add tagged values
dim templateTag as EA.TaggedValue
for each templateTag in modelDocElement.TaggedValues
if templateTag.Name = "RTFTemplate" then
templateTag.Value = template
templateTag.Notes = "Default: Model Report"
templateTag.Update
exit for
end if
next
'add attribute
dim attribute as EA.Attribute
set attribute = modelDocElement.Attributes.AddNew(package.Name, "Package")
attribute.ClassifierID = package.Element.ElementID
attribute.Update
end function

Geert
Title: Re: Model documents and scripts
Post by: Thomas Arnbjerg on March 27, 2024, 10:24:50 pm
Fantastic. Just what I need. Thanks.