One possibility is to create two different representations in the GraphRep code and switch between them using an attribute e.g. „Representation“ (type: Integer). For example you can set Representation to 0 by default and define the GraphRep code for the case that Representation=0. This graphical representation will be then shown in the Toolbox. If you want to model and thus create an instance of the specific class, then you can use an event to change the value of the Representation variable to 1. Then you can define a different graphical representation in the GraphRep attribute for the case Representation = 1.
Example: Different representation for the class „W“ in the Toolbox and the Modelling area:
1. Create an attribute “Representation” of type integer for the class „W“
2. Define the code in the GraphRep attribute for the 2 different cases:
1GRAPHREP layer:-1 sizing:asymmetrical
2
3#get the value of Representation attribute (0 by default) and assign it to the variable rep
4AVAL rep:"Representation"
5
6IF (rep = "0") {
7 #this graphical representation will be shown in the Toolbox
8 FILL color:blue
9 POLYGON 3 x1:-1cm y1:1cm x2:0cm
10 y2:-1cm x3:1cm y3:1cm
11 ATTR "Name" x:0cm y:1cm w:c
12}
13ELSIF (rep = "1") {
14 #this graphical representation will be shown in the Modelling area
15 SHADOW off
16
17 FILL color:blue
18 ELLIPSE x:0.00cm y:0cm rx:1cm ry:1cm
19 FILL color:yellow
20 ELLIPSE x:0.00cm y:0cm rx:0.5cm ry:0.5cm
21
22 ATTR "Name" x:0.00cm y:1.0cm w:c
23}
3. Go to Library attributes→Add-ons and add the event „CreateInstance“ to the External coupling:
1ON_EVENT "CreateInstance" {
2 CC "Core" GET_CLASS_NAME classid:(classid)
3 #--> RESULT ecode:intValue classname:strValue isrel:intValue
4
5 IF (classname = "W") {
6 #if an object of class "W" is created then the value of the "Representation" attribute is changed to 1
7 CC "Core" SET_ATTR_VAL objid:(instid) attrname:("Representation") val:(1)
8 }
9}