Vous pouvez dynamiquement récupérer et définir des propriétés étendues d'objets telles que les attributs et les collections à l'aide de scripts.
La syntaxe pour identifier une propriété d'objet est la suivante :
"<TargetCode>.<PropertyName>"
Par exemple, pour récupérer l'attribut étendu MyAttribute depuis l'objet importXXX, vous utilisez :
GetExtendedAttribute("importXXX.MyAttribute")
Notez que si le script est à l'intérieur d'un profil (par exemple dans un script de vérification personnalisée), vous pouvez utiliser la variable %CurrentTargetCode% à la place de TargetCode codé en dur, afin de favoriser la réutilisation de votre script.
Par exemple :
GetExtendedAttribute("%CurrentTargetCode%.MyAttribute")
Dans l'exemple suivant, nous allons :
If (not ExistingModel Is Nothing) and (not FoundClass Is Nothing) Then ' Modify extended attribute on the class Dim ExaName ExaName = "importXXX.MyAttribute" ' attribute name prefixed by extended model definition code If FoundClass.HasExtendedAttribute(ExaName) Then output "Extended attribute can be accessed" FoundClass.SetExtendedAttributeText ExaName, "1024" FoundClass.SetExtendedAttribute ExaName, 2048 Dim valAsText, valAsInt valAsText = FoundClass.GetExtendedAttributeText(ExaName) valAsInt = FoundClass.GetExtendedAttribute(ExaName) End If ' Modify extended collection on the class Dim ExColName, ExCol ExColName = "importXXX.MyCollection" ' collection name prefixed by extended model definition code Set ExCol = FoundClass.GetExtendedCollection(ExColName) If not ExCol is Nothing Then output "Extended collection can be accessed" ' The extended collection can be used as a standard collection ' for example, we add the class in its own extended collection ExCol.Add FoundClass Set ExCol = Nothing End If End If