cancel
Showing results for 
Search instead for 
Did you mean: 

How list extended attribute PowerDesigner with VB Vbscript ?

pamc_support_2018
Discoverer

Hello,

I try without result, to list all the extended attributes of any object (and specificity EnterpriseApplication object) in PowerDesigner, in VBScript.

I use PowerAMC V16.5 (french version of Power designer), to EA modeling.

if I know the name of each extended attribute, I can do it, like this :

for each App in M.EnterpriseApplications

    App.getExtendedAttribute ("DEf_etendu_Carto_URBA_PAMC_V16.5.ProjetAnneeDebut")
next
where : "DEf_etendu_Carto_URBA_PAMC_V16.5" is my extension file;
and "ProjetAnneeDebut" one of the Extended Attribute

But how know, all the extended attributes ?

I try to do like this :

for each App in M.EnterpriseApplications
    for each ExtAttrib In  .....
      text = ExtAttrib.name & " = " & App.getExtendedAttribute ("DEf_etendu_Carto_URBA_PAMC_V16.5." & ExtAttrib)
    next
next

Thank for all help...

André

pamc_support_2018
Discoverer
0 Kudos

hello,

some complements :

When I try this code :

For Each ModelExtension In ActiveModel.ExtendedModelDefinitions
      output "extension : " & ModelExtension.name
   For Each ExtAttr in ModelExtension.GetMetaExtensionsForClass(PdEAM.cls_EnterpriseApplication, Cls_ExtendedAttributeTargetItem)
     output "Nom de l'attribut : " + ExtAttr.Name
     output "Identification de l'objet : " + ExtAttr.ObjectID
     output "Nom du modele : " + ExtAttr.Model
  Next
Next

the repons to second line, is good :

output "extension : " & ModelExtension.name
                => extension : DEf_etendu_Carto_URBA_PAMC_V16.5

But i have an error message to the 4th line :

Erreur d'exécution Microsoft VBScript
Cet objet ne gère pas cette propriété ou cette méthode: 'ModelExtension.GetMetaExtensionsForClass' (0x800A01B6)
At line 4, character 2

And to more information, look our extensions in screen copy :

and sorry for my so bad english.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member200945
Contributor
0 Kudos

Also confirm that the original code works on 16.6 SP7

For Each ModelExtension In ActiveModel.ExtendedModelDefinitions
      output "extension : " & ModelExtension.name
   For Each ExtAttr in ModelExtension.GetMetaExtensionsForClass(PdEAM.cls_EnterpriseApplication, Cls_ExtendedAttributeTargetItem)
     output "Nom de l'attribut : " + ExtAttr.Name
     output "Identification de l'objet : " + ExtAttr.ObjectID
     output "Nom du modele : " + ExtAttr.Model
  Next
Next
 
former_member200945
Contributor
0 Kudos

The code can find all items in all extensions in a model. So I add two if statements to restrain the output

GeorgeMcGeachie
Active Contributor
0 Kudos

The code fails if the extension is not embedded in the model, as shortcuts don't have any collections. This version of the code ignores non-embedded extensions:

Set model = ActiveModel  
'1st loop finds how many Extension in the model
for each ExtendedDefinition in  model.ExtendedModelDefinitions
   '2nd loop finds all folders in the ExtendedDefintion.
          'Generation
          'Settings
          'Profile 
   if not ExtendedDefinition.IsShortcut() then 
      for each foldername in ExtendedDefinition.Categories
          '3rd loop go through each folder. All extended attributes are defined in
              'Profile
           
          'if foldername.name = "Profile" then
            for each metaClass in foldername.Categories
                '4th loop go through each metaClass in all folders.
                'Only Profile folder contains metaClass
                for each ExtendedAttributeFolder in metaClass.Categories
                    '5th loop go through Extended Attributes folder
                    'Find all extended attributes
                    if ExtendedAttributeFolder.name ="Extended Attributes" then
                        for each extendedAttribute in ExtendedAttributeFolder.Categories
                             output ExtendedDefinition.name & "\" & extendedAttribute.itemPath & "\" & extendedAttribute.name
                        next
                    end if
                next
            next 
         'end if
      next
   end if ' IsShortcut
next

former_member200945
Contributor
0 Kudos
Set model = ActiveModel  
'1st loop finds how many Extension in the model
for each ExtendedDefinition in  model.ExtendedModelDefinitions
   '2nd loop finds all folders in the ExtendedDefintion.
          'Generation
          'Settings
          'Profile 
   for each foldername in ExtendedDefinition.Categories
       '3rd loop go through each folder. All extended attributes are defined in
           'Profile
           
       if foldername.name = "Profile" then
         for each metaClass in foldername.Categories
             '4th loop go through each metaClass in all folders.
             'Only Profile folder contains metaClass
             for each ExtendedAttributeFolder in metaClass.Categories
                 '5th loop go through Extended Attributes folder
                 'Find all extended attributes
                 if ExtendedAttributeFolder.name ="Extended Attributes" then
                     for each extendedAttribute in ExtendedAttributeFolder.Categories
                          output ExtendedDefinition.name & "\" & extendedAttribute.itemPath & "\" & extendedAttribute.name
                     next
                 end if
             next
         next 
      end if
   next
next