PowerDesigner how to get consistent entity colour on different diagrams

351 Views Asked by At

I have designed a large conceptual data model using PD 16.5. The model covers different data domains, for example Fund, Asset, Finance, etc. and for each set of entities within a domain I have coloured them differently. So all Fund entities are blue, all Asset entities are green. This works well and is a good visual cue when looking at the model.

One of the benefits of doing a model in PD is that once you create the entities, you can create multiple diagrams and just drag and drop the entities in to show different views, etc. But when I drag a Fund entity onto my new diagram, for example, the formatting I had in the other diagram is not brought across with the entity.

Is there a way of maintaining the formatting of the Entities between diagrams?

Thanks

M

1

There are 1 best solutions below

1
pascal On

I have a suggestion, which is not satisfying... with a script, to apply a color schema on request. This script can be implemented in a custom method, called from a custom menu attached to the Model, in an Extension.

For example, I just provided a silly FormatEntity sub, to pick a color depending on the Entity name...

But you could have an Extended Association on entities, pointing to the main Folder (Package, or Model) for each entity; extended attributes on the BaseFolder, which provides the graphical elements you want to set on each entity; and a custom handler associated with the Extended Association, which updates the entity symbol depending on the selected folder...

option explicit

sub FormatEntity(s)
   dim o
   set o = s.Object
   ' TODO deal with shortcut case
   if not o is nothing and o.ClassKind <> cls_Shortcut then
      dim name : name = o.Name
      output "seeing " & name
      if instr(name,"0")+instr(name,"3")+instr(name,"6")+instr(name,"9")<>0 then
         output "setting "&name&" to red"
         s.FillColor = &hFF ' red
      elseif instr(name,"1")+instr(name,"4")+instr(name,"7")<>0 then
         output "setting "&name&" to green"
         s.FillColor = &hFF00 ' green
      else
         output "setting "&name&" to blue"
         s.FillColor = &hFF0000 ' blue
      end if
   end if
end sub

sub ExploreOneDiagram(diag)
   dim s
   for each s in diag.Symbols
      if s.ClassKind = cls_EntitySymbol then
         FormatEntity s
      end if
   next
end sub

sub ExploreDiagrams(folder)
   dim d
   for each d in folder.AllGraphicalDiagrams
      'output folder.name&"."&d.name
      ExploreOneDiagram d
   next
end sub

ExploreDiagrams ActiveModel
dim p
for each p in ActiveModel.Packages
   ExploreDiagrams p
next