Most metamodel navigation is performed by descending from the model root through collections of objects to collections of sub-objects or associated objects. An OOM contains a collection of classes and classes contain collections of attributes and operations. You can obtain information about and browse the members of a collection through scripting, as well as adding, removing, and moving objects in the collection.
Dim MyModel
Set MyModel=ActiveModel
For each t in MyModel.Tables
    Output "* " & t.Name
Next
When
            you browse a collection, both full objects in the collection and any shortcuts will be
                retrieved.Compositions - contain objects that will be deleted if the parent is deleted. For example, the PdPDM/Tables and PdPDM/Table/Columns collections are compositions.
Aggregations - reference objects that will continue to exist if the parent is deleted. For example, the PdCommon/NamedObject/AttachedRules collection (inherited by most objects) is an aggregation.
Unordered collections - contain objects with no significant order. For example, the PdCDM/Entity/Relationships collection is unordered.
Ordered collections - contain objects where the user chooses the order. For example, the PdPDM/Table/Columns collection is ordered.
Read-only collections - can only be browsed. For example, the global Models collection (all open models) is read-only.
Dim MyModel, t, r, sym
set MyModel = CreateModel(PdPDM.Cls_Model,"DBMS=SYASA12")
MyModel.SetNameAndCode "MyPDM" , "MyPDM"
'Create tables and rules
For idx = 1 to 12
   Set t=MyModel.Tables.CreateNew()
   t.SetNameAndCode "T" & idx, "T" & idx
   Set sym=ActiveDiagram.AttachObject (t)
   Set r=MyModel.BusinessRules.CreateNew()
   r.SetNameAndCode "BR" & idx, "BR" & idx
Next
ActiveDiagram.AutoLayoutWithOptions(2)
'Attach rules to Table 1
   Dim MyTable
   Set MyTable=MyModel.FindChildByName("T1",cls_table)
   For idx = 1 to 10
      MyTable.AttachedRules.Add(MyModel.FindChildByName("BR" & (idx),cls_businessrule))
   Next
'Print list of rules attached to Table 1
Output "Rules Attached to T1 (" & MyTable.AttachedRules.Count & ")"
For each r in MyTable.AttachedRules
    Output "* " & r.Name
Next
'Modify attached rules by insertion, move and removal
MyTable.AttachedRules.Insert 3, MyModel.FindChildByName("BR12",cls_businessrule)
MyTable.AttachedRules.Move 5,0
MyTable.AttachedRules.Remove(MyModel.FindChildByName("BR6",cls_businessrule))
'Print modified list of rules
Output "Modified Rules Attached to T1 (" & MyTable.AttachedRules.Count & ")"
For each r in MyTable.AttachedRules
    Output "* " & r.Name
Next