If there is a manual way to place colors on tables using stereotypes?

0 votes
asked by about Sybase PowerDesigner

I import an excel file into PowerDesigner as a physical data model. The excel file associates a stereotype with each table. My stereotypes are “hub”, “sat”, “lnk”... and I'd like to be able to automatically color the tables according to the stereotype. Example: if stereotype hub, then the table is colored blue, if lnk, the table is colored red, but automatically because I have a file with 200 tables and doing it by hand is much too time-consuming. Especially since I need scalability.

I tried to add an extension, to associate a color for each stereotype but I encountered a problem, to apply the color to the table, I have to click on each table and reselect the stereotype, so not too manually. So I wanted to know if there is a manual way to do this.

===> My aim is to associate each stereotype with a color and have the table take that color, all automatically.

The result I want to have if I say that the Link stereotype is associated with the color red

So far, I've been working on an extension to add a color to each stereotype, but the problem is that the tables don't change color automatically. So here's the stereotype for lnk :

1 Answer

0 votes
answered ago by (98.2k points)

To address your question:

To automatically color tables in Sybase PowerDesigner based on their stereotypes, you can create a script that loops over all tables and applies the color according to the stereotype. Unfortunately, PowerDesigner doesn't have built-in functionality to directly associate colors with stereotypes that would automatically update upon importing. However, you can use the scripting language available in PowerDesigner to automate this task. Here's a general approach using VBScript:

  1. Open PowerDesigner and load your model.
  2. Go to Tools -> Execute Commands -> Edit/Run Script.
  3. Use a script like the following to automatically apply colors:
Option Explicit
Dim mdl 'the current model
set mdl = ActiveModel

if (mdl Is Nothing) or not mdl.IsKindOf(PdPDM.cls_Model) then
   MsgBox "There is no valid Physical Data Model open in PowerDesigner.", vbCritical
Else
   Dim tab 'a table object
   For Each tab In mdl.Tables
      Dim stereotype, color
      stereotype = tab.GetAttribute("Stereotype")
      Select Case stereotype
         Case "hub"
            color = RGB(0, 0, 255) ' Blue
         Case "sat"
            color = RGB(0, 255, 0) ' Green
         Case "lnk"
            color = RGB(255, 0, 0) ' Red
         ' Add more cases as needed
         Case Else
            color = RGB(255, 255, 255) ' Default White
      End Select
      tab.BackgroundColor = color
   Next
   MsgBox "Coloring complete!", vbInformation
End If
  1. Adjust the RGB values and stereotypes in the script as per your requirements.
  2. Run the script.

This script uses the RGB color system to define the colors and applies them to tables based on the stereotype. It should streamline your process for models with numerous tables.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register
...