Accessing Metadata (Scripting)

You can explore the structure of the PowerDesigner metamodel as a standalone model or starting from object instances in your model.

For general information about accessing and navigating in the metamodel, see The PowerDesigner Public Metamodel. Metaclasses (such as CheckModelInternalMessage and FileReportItem) that are not accessible by script are visible in Metamodel.oom, but bear the <<notScriptable>> stereotype and are not listed in the Metamodel Object Help file.

You can access metaclasses, metaattributes, and metacollections by iterating over collections descending from the MetaModel root or individually through the following methods:
The following script traverses the metamodel by library and lists each concrete class:
for each l in MetaModel.Libraries
   for each c in l.Classes
      if c.Abstract = false then
         Output l.PublicName + "." + c.PublicName
      end if
   next
next
The following script locates the BaseClass root and shows the first two levels of inheritance under it:
set root = MetaModel.GetMetaClassByPublicName("PdCommon.BaseObject")
for each c in root.Children
   output c.PublicName
   for each cc in c.Children
      output "    " + cc.PublicName
   next
next
The following script obtains a table in a PDM, and then shows the metaclass of which the object is an instance, the parent metaclass and metalibrary to the metaclass, and all the attributes and collections that are available on that metaclass:
Dim object
Set object = ActiveModel.FindChildByName("myTable",cls_Table)
Output "Object: " + object.Name

Dim metaclass
Set metaclass = object.MetaClass
Output "Metaclass: " + metaclass.PublicName 
Output "Parent: " + metaclass.Parent.PublicName
Output "Metalibrary: " + metaclass.Library.PublicName
Output "Attributes:"
For each attr in metaclass.attributes
   Output " - " + attr.PublicName
Next
Output "Collections:"
For each coll in metaclass.collections
   Output " - " + coll.PublicName
Next

Properties and collections are read-only for all metamodel objects.