16-01-2019 10:14 AM
Hello,
We would like list with VB Script, all MetaClass that can be displayed on a diagram.
We use the instruction below :
Dim clMOAE ‘ Collection of MetaOppositeAssociationEnd
Dim oMOAE ‘ Object MetaOppositeAssociationEnd
Dim oMcDiag ‘ MetaClass Diagram
Set clMOAE = oMcDiag.Getcollection("MetaOppositeAssociationEnd")
--> 259 links are found
Then, we retreive the MetaClass of each link with the instruction below :
oMOAE.GetCollection("MetaClass")(1).Name
But in a diagram object, we see other links : for exemple « Elément d’un diagramme ». This link contains several metaclass : flow, site…
We thank you for advance
19-02-2019 02:17 PM
Finally, I wrote the script below which works.
Option Explicit
const ASCENDING = 1
Sub MainRoot(oRoot)
Dim oMetaClass, oMAE, cMAE, oMtConcrete, cMtConcrete
Dim iAbstractLevel
' Metaclas Diagramme
oMetaClass = GetObjectFromId("~KekPBSs3iS10[Diagramme]") ' Copy / Past of object
oRoot.print " --> MetaAssociationEnd (with abstract MetaAssoicationEnd) "
Set cMAE = oMetaClass.GetRoot.GetCollectionDescription(oMetaClass.GetID).Collections
' Access to "Elément dans diagramme" collection
Set oMAE = oMetaClass.GetRoot.GetCollectionDescription(oMetaClass.GetID).Collections.Item("Elément dans diagramme")
oRoot.print "Number MAE : " & cMAE.count
oRoot.print " "
For Each oMAE in cMAE
' Abstract level : 1 = abstract, 0 = concrete
iAbstractLevel = oMetaClass.GetRoot.GetClassDescription(oMAE.megaField).GetProp("Abstraction")
oRoot.Print oMAE.GetProp("Name") & " Abstract level : " & oMetaClass.GetRoot.GetClassDescription(oMAE.megaField).GetProp("Abstraction")
If oMAE.GetProp("Name") = "Elément dans diagramme" Then
' Retreive concrete MetaAssociationEnd
set cMtConcrete = oMetaClass.GetRoot.GetCollectionDescription(oMAE.megaField).Concretes
oRoot.print " Number concrete MAE : " & cMtConcrete.count
' Display concrete MAE
For each oMtConcrete in cMtConcrete
oRoot.print " Name : " & oMtConcrete.GetProp("Name") & " MegaField : " & oMtConcrete.megaField
Next
End If
Next
' Free memory
Set oMetaClass = Nothing
Set oMAE = Nothing
Set cMAE = Nothing
Set oMtConcrete = Nothing
Set cMtConcrete = Nothing
End Sub
17-01-2019 05:08 PM
Thank you.
Is it possible to do that by VB Script ?
17-01-2019 03:22 PM
Explore the MetaClass 'Element in diagram' and see its sub MetaClass
17-01-2019 03:17 PM
Hello,
Thank you. I read the page and I tested the solution on my diagram object as below.
Dim cBE, cOP
Set cBE = oDiag.GetCollection("Elément dans diagramme")
Print "Number of Elément dans diagramme objects : " & cBE.count()
' Display all objects of "Elément dans diagramme"
For each oObjet in cBE
print oObjet.GetProp("Nom court")
Next
' Display the number of objects of metaclass Flux in "Elément dans diagramme"
Set cOP = cBE.GetType("~CK0MCRcD9bV1[Flux]")
print Print "Number of Flux objects: " & cOP.count()
We would like to list all links (inherited or not) in order to avoid writing each name of link. Is it possible for a diagram metaclass ? for a diagram object ?
Then, for each link, we would like to know which is the metaclass.
A links can have several metaclass (ex « Elément dans diagramme »). Is it possible to identify such link ? Is it possible to list all metaclass of this link ?
Thank you
16-01-2019 12:22 PM
Hello
This is a more general concern with Abstract metamodel
Use GetType to test the Sub MetaClass of the target MetaClass
See this page of MEGA Community