This package provides an implementation of a mechanism that adds Interrefs to selected objects contained in the actual model ("filling"). For every object (of a predefined class) from a selected target model, one Interref pointing to this object is added.
The first two images below show the selection of object A and the selection of Template Model 1 as target model. The result can be seen in the third image: every object contained in Template Model 1 is referenced in object A.
Downloads
The files below contain an example library (Fill Objects.abl) and anexample model (Fill Objects Demonstration Model.adl). A step-by-step configuration guide is presented in the Hands-On section below. It completely describes how to build this example library and contains the code of the mechanism.
Fill Objects.abl Fill Objects Demonstration Model.adl Description of the MechanismFunctionality provided by ADOxx
ADOxx Realisation Approach
- Pressing the Fill-Button (c.f. buttons on the drawing area) triggers the mechanism
- Get all IDs of objects in the actual model.
- Create a TreeListBox and insert all objectids (from 2.)
- User selects objects listet in the TreeListBox
- Get all IDs of Models of certain model type (e.g. Template Container Sample)
- Create a TreeListBox and insert all modelids (from 5.)
- User selects a model listet in the TreeListBox
- Get all objects in the selected model
- Add one Interref for each object (from 8.) to selected objects (from 4.)
Used Modeling Language for Demonstration of the Mechanism
- modeltype: Default Filling Sample, Template Container Sample
- classes: __ModelTypeMetaData__, A, B
- attributes: Fill Objects Button Graphrep (Longstring), _FillObjects_ (Programcall).
Hands-On1) PreparationsCreation of before mentioned classes & attributes for the sake of a minimal working example. This step can be skipped – import
Fill Objects.abl instead.
a) Define new classes A, B __ModelTypeMetaData__- Go to the Library management, select a dynamic library and click Class hierarchy.
- Click View and select Metamodel.
- Select __D-construct__ (Metamodel)
- Click New --> New class; name it A
- Click New --> New class; name it B
- Click New --> New class; name it __ModelTypeMetaData__
b) Add new attributes to class __ModelTypeMetaData__- Select class __ModelTypeMetaData__
- Click New --> New attribute...
- Name new attributes and select type according figure above: (1) name: Fill Objects Button Graphrep, type: Longstring (2) name: _FillObjects_, type: Programcall.
c) Configure Fill Objects Button GraphRep attribute- Double click Fill Objects Button GraphRep attribute, set Standard value:
1GRAPHREP layer:-3
2IF (_outdevtype = "drawingarea") {
3SET fillIcon:"db:\\btn_fill.png"
4BITMAPINFO (fillIcon)
5BITMAP (fillIcon) x:1cm y:0.5cm w:1.5cm h:1.5cm
6HOTSPOT "_FillObjects_" text:"Fill Objects" x:1cm y:0.5cm w:1.5cm h:1.5cm
7}
- Make sure that the file btn_fill.png is contained in the database (close the Library management and go to Extras --> File management…).
d) Configure _FillObjects_ attribute (Programcall)- Select class __ModelTypeMetaData__
- Double click _FillObjects_ attribute
- Set standard value to: Fill Object
- Click Facets and set EnumerationDomain to:
1ITEM "Fill Objects"
2EXECUTE file: ("db:\\fill objects.asc")
- Make sure that the file fill objects.asc is contained in the database
e) Definine Modeltypes- Go back to the Library management and select your current Dynamic Library.
- Click Library attributes… --> Add-ons and define the following model type according the figure above:
1MODELTYPE "Default Filling Sample" from:none plural:"Default Filling Samples" pos:0 not-simulateable bitmap:"db:\\sample.bmp" graphrep: "Fill Objects Button GraphRep"
2INCL "A"
3MODELTYPE "Template Container Sample" from:none plural:"Template Container Samples" pos:1 not-simulateable bitmap:"db:\\Sample2.bmp"
4INCL "B"
f) Create Interref attribute in class A- Select class A
- Click New --> New attribute...
- Name new attribute: name: References, type: Interref
g) Configure Inerref attribute- Double click on new attribute Refereces --> click Facets.
- Click the Dialog button of the AttributeInterRefDomain attribute, see figure above.
- Select Instance references, click Add…, select Model type Template Container Sample and Class B and apply (twice).
h) Configure AttrRep attribute (Class A)- Go to class A
- Double click on attribute AttrRep (Metamodel) --> click Facets.
- Add the following line to Standard Value:
1ATTR "References" lines:15
i) Configure GraphRep of class A- Go to class A.
- Double click GraphRep (Metamodel).
- Click the Dialog button.
- Enter:
1GRAPHREP
2SHADOW off
3FILL color:blue
4ELLIPSE x:0.00cm y:0cm rx:1cm ry:1cm
5ATTR "Name" x:0.00cm y:1.0cm w:c
j) Configure GraphRep of class B1GRAPHREP
2SHADOW off
3FILL color:red
4ELLIPSE x:0.00cm y:0cm rx:1cm ry:1cm
5ATTR "Name" x:0.00cm y:1.0cm w:c
2) Implementation of Mechanism with AdoScript
1[size=4][size=2]CC "Modeling" GET_ACT_MODEL
2SET iModelID: ( modelid )
3
4# Class to be filled:
5SET sClassName: "A"
6# Attribute to be filled:
7SET sAttrName: "References"
8
9CC "Core" GET_CLASS_ID classname: (sClassName)
10SET iClassID: ( classid )
11
12# Target Model type for filling:
13SET sModelType: "Template Container Sample"
14
15# Selection of objects to be filled:
16#=======================================
17#TREE_LIST_BOX
18CC "AdoScript" TLB_CREATE title: "Fill objects"
19 oktext: "Fill" canceltext: "Cancel"
20 boxtext: "Select objects to be filled"
21 no-help: 1
22 x: 50
23 y: 50
24 sizeable: 1
25 checklistbox: 1
26 # get all objects of predefined class in predefined model:
27 CC "Core" GET_ALL_OBJS_OF_CLASSNAME modelid: (iModelID) classname: (sClassName)
28 # add objects to TreeListBox:
29 FOR sObjectID in: ( objids ) {
30 SET idObjectID: ( VAL sObjectID)
31 CC "Core" GET_OBJ_NAME objid: (idObjectID)
32 CC "AdoScript" TLB_INSERT id: (idObjectID) text: ( objname ) parentid: (iModelID)
33 }
34# show TreeListBox
35CC "AdoScript" TLB_SHOW
36IF (endbutton != "ok")
37{
38 EXIT
39}
40# selected objects:
41SET sListOfIDs: (selectedids)
42#TREE_LIST_BOX END
43#=======================================
44
45# Selection of template model
46#=======================================
47# TREE_LIST_BOX
48CC "AdoScript" TLB_CREATE title: "Select Template Model"
49 oktext: "OK" canceltext: "Cancel"
50 boxtext: "Select model"
51 no-help: 1
52 x: 50
53 y: 50
54 sizeable: 1
55 checklistbox: 0
56 # get all models of certain model type:
57 CC "AQL" EVAL_AQL_EXPRESSION expr: ("<\""+sModelType+"\">") modelscope
58 SETL lModelIDs: (objids)
59 # add models to TreeListBox
60 FOR sModelID in: (lModelIDs) {
61 SET idModelID: ( VAL sModelID)
62 CC "Core" GET_OBJ_NAME objid: (idModelID)
63 CC "AdoScript" TLB_INSERT id: (idModelID) text: ( objname )
64 }
65# show TreeListBox
66CC "AdoScript" TLB_SHOW
67IF (endbutton != "ok")
68{
69 EXIT
70}
71# selected models:
72SET sTemplateModel: (selectedids)
73SET iTemplateModelID: ( VAL sTemplateModel)
74# TREE_LIST_BOX END
75#=======================================
76
77# Fill Objects with References --> selected objects (1st TreeListBox) are filled with all objects contained in template model (2nd TreeListBox):
78FOR iObject in: (sListOfIDs) {
79CC "Core" LOAD_MODEL modelid: (iTemplateModelID)
80CC "Core" GET_ALL_OBJS modelid: (iTemplateModelID)
81SETL sListofAllObjects: (objids)
82CC "Core" GET_ATTR_ID classid: (iClassID) attrname: (sAttrName)
83SET iAttrID: (attrid)
84
85FOR sObject in: (sListofAllObjects) {
86 CC "Core" ADD_INTERREF objid: ( VAL iObject) attrid: (iAttrID) tmodelid: (iTemplateModelID) tobjid: (VAL sObject)
87 }
88CC "Core" DISCARD_MODEL modelid: (iTemplateModelID)
89}[/size][/size]