As any PowerDesigner object, extended model definitions can be read, created and modified using scripting.
For more information on extended model definitions, see Extended Model Definitions.
The following script illustrates how you can access an existing extended model definition, browse it , create an extended attribute within the definition and at last modify the extended attribute values. A function is created to drill down the categories tree view that is displayed in the Extended Model Definition Properties dialog box.
Dim M Set M = ActiveModel 'Retrieve first extended model definition in the active model Dim X Set X = M.ExtendedModelDefinitions.Item(0) 'Drill down the categories tree view using the searchObject function (see below for details) Dim C Set C = SearchObject (X.Categories, "Settings") Set C = SearchObject (C.Categories, "Extended Attributes") Set C = SearchObject (C.Categories, "Objects") Set C = SearchObject (C.Categories, "Entity") 'Create extended attribute in the Entity category Dim A Set A = C.Categories.CreateNew (cls_ExtendedAttributeTargetItem) 'Define properties of the extended attribute A.DataType = 10 'integer A.Value = 10 A.Name = "Z" A.Code = "Z" 'Retrieve first entity in the active model Dim E Set E = M.entities.Item(0) 'Retrieve the values of the created extended attribute in a message box msgbox E.GetExtendedAttribute("X.Z") 'Changes the values of the extended attribute E.SetExtendedAttribute "X.Z", 5 'Retrieve the modified values of the extended attribute in a message box msgbox E.GetExtendedAttribute("X.Z") ******************** 'Detail SearchObject function that allows you to browse a collection from its name and the searched object '* SUB SearchObject Function SearchObject (Coll, Name) 'For example Coll = Categories and Name = Settings Dim Found, Object For Each Object in Coll If Object.Name = Name Then Set Found = Object End If Next Set SearchObject = Found End Function