预订演示

请注意 : 本帮助页面不适用于最新版本的Enterprise Architect. 最新的帮助文档在这里.

前页 后页

Add and Manage Diagrams

This is an example of the code for creating a diagram and adding an element to it. Note the optional use of the element rectangle setting, using left, right, top and bottom dimensions in the AddNew call.

     Sub DiagramLifeCycle

          Dim diagram as object
          Dim v as object
          Dim o as object
          Dim package as object

          Dim idx as Integer
          Dim idx2 as integer

          package = m_Repository.GetPackageByID(5)

          diagram = package.Diagrams.AddNew("Logical Diagram","Logical")
          If not diagram.Update Then
               Console.WriteLine(diagram.GetLastError)
          End if

          diagram.Notes = "Hello there this is a test"
          diagram.update()

          o = package.Elements.AddNew("ReferenceType","Class")
          o.Update

          '' add element to diagram - supply optional rectangle co-ordinates

          v = diagram.DiagramObjects.AddNew("l=200;r=400;t=200;b=600;","")
          v.ElementID = o.ElementID
          v.Update

          Console.WriteLine(diagram.DiagramID)

     End Sub