on 07-31-2014 3:52 PM
I'm using PD 16.5 SP03 PL03.
I need to extract a CSV file that contains selected metadata from the entity attributes that are displayed in a LDM diagram. Nothing works.
If I create a Generated File containing GTL, no preview tab appears in the diagram properties (this approach works for the model and entities, but not for the diagram).
If I write a simple VB Script to extract metadata via the DisplayedObjects collection, I get an error message that says the Class doesn't support automation.
Is there another way?
Hi George,
That's true, diagrams don't inherits from Extensible, as you can see in MetaModel Help. Therefore, you cannot extent them.
The GUI is poorly offering you all these capacities although they are useless for Diagrams.
That said, some extensions have been added however, and you can work with extended attributes and VBS (not GTL).
For instance, you can create a read-only computed extended attribute of type Text, called XPreview.(avoid name that can conflict with metamodel names).
You can add it in a new Form (named Preview)
This computed attribute would contain call to your collections
The "%Get%" output value will be displayed in the Preview form.
But you must take care of metamodel limitations concerning diagrams. Also a diagram does not hold object, only symbols.
So to access object data, you must use the Object property of ObjectSymbol class.
Good luck
Marc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Marc. I had tried using the DisplayedObjects collection, which didn't work. The 'Symbols' collection does work, as you suggested, though I don't understand why it doesn't.
This script works:
dim myDiagram
set myDiagram = ActiveDiagram
Output "Diagram " & myDiagram & " has " & myDiagram.Symbols.Count & " symbols"
for each mySymbol in myDiagram.Symbols
if mySymbol.Object.iskindof(pdLDM.cls_Entity) then
output mySymbol.Object.Name & "," & mySymbol.Object.Code & "," & mySymbol.Object.Comment
end if
next
Now I just have to work out how to surround each entry with double quotes for the CSV file, and how to prevent it throwing an error when it runs out of entities.
George
Hi,
You may use the EvaluateTextFor on Object, and use the .Q macro to quote the desired properties.
Ex.
<<
Function %Get%(obj)
dim sym, sobj, str
for each sym in obj.Symbols
if (sym.isKindOf(cls_ObjectSymbol)) then
if(str <> "") then str = str & vbCrLf
str = str & sym.Object.EvaluateTextFor("%.Q:ClassName%\t%.Q:Code%\t%.Q:Name%\t%.Q:Comment%", "%CurrentTargetCode%")
end if
next
%Get% = str
End Function
>>
Nice [productive] solution will be to add a template in "NamedObject" with a default description, ie <<%.Q:Code%\t%.Q:Name%\t%.Q:Comment%>>
that you may override in specific object type. For instance, Entity would display specifc properties, and attributes others.
You will have a template (say "xlsDump") under NamedObject with a default contents.
But in Entity, the same template will have additional parent entity for instance, so the same template "xlsDump" will contain <<%.Q:Code%\t%.Q:Name%\t%.Q:Comment%\t[%ParentEntity%?%.Q:ParentEntity.Name%:"No parent"]>>
Ex.
NamedObject.xlsDump=
%.Q:ClassName%\t%.Q:Code%\t%.Q:Name%\t%.Q:Comment%
Entity.xlsDump=
%.Q:ClassName%\t%.Q:Code%\t%.Q:Name%\t%.Q:Comment%\t[%ParentEntity%?%.Q:ParentEntity.Name%:"No parent"]\n
.foreach_item("Attributes")
%xlsDump%
.next("\n")
EntityAttribute.xlsDump=
%.Q:ClassName%\t%.Q:Code%\t%.Q:Name%\t%.Q:Comment%\t%.Q:DataType%
You LogicalDiagram.XPreview extended attribute Get Method Script =
Function %Get%(obj)
dim sym, sobj, str
for each sym in obj.Symbols
if (sym.isKindOf(cls_ObjectSymbol)) then
if(str <> "") then str = str & vbCrLf
str = str & sym.Object.EvaluateTextFor("%xlsDump%", "%CurrentTargetCode%")
end if
next
%Get% = str
End Function
You will have a preview page as
<<
"Entity" "CAR" "Car" "Car vehicle" "Vehicle"
"Entity Attribute" "NUMBEROFSEATS" "NumberOfSeats" "" "I"
"Entity Attribute" "TYPE" "Type" "" "VA128"
"Entity Attribute" "CONDUCTORSEATSLEFT" "ConductorSeatsLeft" "" "BL"
"Entity" "VEHICLE" "Vehicle" "" "No parent"
"Entity Attribute" "NUMBEROFSEATS" "NumberOfSeats" "" "I"
"Entity Attribute" "TYPE" "Type" "" "VA128"
"Inheritance" "INHERITANCE_1" "Inheritance_1" ""
>>
for a simple model Vehicule(NumberOfSeats,Type) <-[inhr]--Car(ConductorSeatsLeft)
Marc
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.