This is the fifth part in a series of VBA tips, in which we will demonstrate how the user can create and customize his or her diagrams, symbols, and definitions in System Architect. From within the VBA editor in the Tools, Macros menu, we created a Process Chart and two elementary business processes connected by a line symbol.
In the last tip, we explored the positioning of a symbol in the diagram. In this tip, we will take a closer look at the many properties available to the user within System Architect. We will experiment with the Symbol Fields as well as some more Symbol class attributes to use in manipulating the aesthetics of our diagram.
We finished last week with the following code:
Manipulating the aesthetics of symbols on a diagram
Every symbol has a number of properties associated with it. Many of these are accessible directly through the object model; additional ones are available through the SetField method of a symbol.
-
In the Immediate window, type the following (making sure to type the period at the end) and view the drop-down list of properties and methods):
SaLineSym.
Notice you can set properties such as FillColor, FontColor, PenColor, PenStyle, etc. These properties were added to the object model because they were deemed the most used properties. However, there are a raft more that can be set or obtained by using the SetField or GetField methods. This internal collection of properties is know as the Symbol Fields.
-
Type the following in the Immediate window (be sure to type the open parenthesis):
SaLineSym.SetField(
-
Review the list of field properties for a symbol that you can set. All of these properties are explained in the Extensibility Guide.
-
We will select the field that sets the location of the line symbol's name. Select SYMFLD_NAMELOC and provide a value as a text string - in quotations specify an X-position of 400 and a Y-position of 190 - completing the line in the Immediate window as follows:
saLineSym.SetField (SYMFLD_NAMELOC, "400 190")
then delete the open and closed parenthesis to make the line:
saLineSym.SetField SYMFLD_NAMELOC, "400 190"
-
Hit Enter and view the open diagram in System Architect. Note how the name of the line symbol has been repositioned.
-
Cut and paste this line from the Immediate window into your code, above the Set MyDiagram = Nothing line.
Coloring symbols
To color a symbol, you must specify an RGB (red, green, blue) color. Exact numbers for RGB colors can be found in most paint programs - for example, black is (0 0 0), red is (255 0 0), green is (0 255 0), blue is (0 0 255), white is (255 255 255), purple is (192 0 192), etc.
Let's change the color of the first EBP symbol to red.
-
In the Immediate window, type in the following:
Sasymbol1.FillColor = RGB(0, 0, 255)
and hit Enter. Notice how the color of Symbol1 changes to blue on the diagram.
-
Cut and paste this line into your code, placing it under the line that reads Set saSymbol1 = MyDiagram.CreateSymbol("Symbol1", ETCATELEMBUSPROC).
-
Let's change the color of the other symbol to blue, adding the following line:
Sasymbol2.FillColor = RGB(0, 0, 255)
underneath Set saSymbol2 = MyDiagram.CreateSymbol("Symbol2", ETCATELEMBUSPROC)
Save the diagram
Finally, let's add a command to save the diagram. This will save the our diagram and symbols in the System Architect repository. Note: if you do not invoke the Save attribute, all the symbols on the "My Diagram" diagram will be deleted when you close System Architect. Thus, it is necessary to save the diagram at the end of our macro.
-
Before the line Set MyDiagram = Nothing, add the following statement:
MyDiagram.Save
Your final code should look as follows:
Save the VBA project by selecting File, Save Tutorial in the VBA IDE.
Next tip
In this tip we illustrated how using the Symbol Fields can add to our design, and experimented with the FillColor attribute to add a bit of flavor to the diagram. In the next tip, we will create a definition and later on explore its meta properties.