Author Topic: Model documents and scripts  (Read 11868 times)

Thomas Arnbjerg

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
    • View Profile
Model documents and scripts
« on: March 27, 2024, 07:30:36 pm »
Is there a way to modify the packages in a model document from a script?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13000
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Model documents and scripts
« Reply #1 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

Thomas Arnbjerg

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
    • View Profile
Re: Model documents and scripts
« Reply #2 on: March 27, 2024, 10:24:50 pm »
Fantastic. Just what I need. Thanks.