Displaying, Formatting, and Positioning Symbols (Scripting)

When you create an object, it will not appear in a diagram unless you use the AttachObject() or AttachLinkObject() method. Symbols are objects in their own right that can be accessed via collections on the parent object or diagram. You can position a symbol using the Position() method and change its format using the LineWidth and other formatting attributes.

The following script creates two classes, joins them by an association link, and displays all three symbols in the active diagram:
Dim MyModel, MyDiagram, C1, C2, A1
Set MyModel = ActiveModel
Set MyDiagram = ActiveDiagram
' Create classes
Set C1 = MyModel.Classes.CreateNew()
C1.SetNameAndCode "C1", "C1"
Set C2 = MyModel.Classes.CreateNew()
  C2.SetNameAndCode "C2", "C2"
' Display class symbols
MyDiagram.AttachObject(C1)
MyDiagram.AttachObject(C2)
' Create association
Set A1 = MyModel.Associations.CreateNew()
A1.SetNameAndCode = "A1", "A1"
' Define its extremities
Set A1.Object1 = C1
Set A1.Object2 = C2
' Display Association symbol
MyDiagram.AttachLinkObject(A1)
The following script creates an EAM and four architecture areas, aligns them in a square, and formats the top-left area:
Dim NewModel, idx, obj, sym
set NewModel = CreateModel(PdEAM.Cls_Model, "Diagram=CityPlanningDiagram")
NewModel.SetNameAndCode "MyEAM" , "MyEAM"
For idx = 1 to 4
   Set obj=NewModel.ArchitectureAreas.CreateNew()
   obj.SetNameAndCode "A" & idx, "A" & idx
   Set sym=ActiveDiagram.AttachObject (obj)
   sym.width=30000
   sym.height=20000
Next
dim A1, A2, A3, A4, X1, Y1
set A1 = NewModel.FindChildByName("A1",cls_architecturearea).Symbols.Item(0)
set A2 = NewModel.FindChildByName("A2",cls_architecturearea).Symbols.Item(0)
set A3 = NewModel.FindChildByName("A3",cls_architecturearea).Symbols.Item(0)
set A4 = NewModel.FindChildByName("A4",cls_architecturearea).Symbols.Item(0)
X1 = A1.Position.X
Y1 = A1.Position.Y
' Move symbols for them to be adjacent
A2.Position = NewPoint(X1 + A1.Width, Y1)
A3.Position = NewPoint(X1, Y1 - A1.Height)
A4.Position = NewPoint(X1 + A1.Width, Y1 - A1.Height)
A1.DashStyle = 2
A1.LineWidth = 3