0

I can use VBA to loop through the columns of a table and change many properties related to the Column object itself. What I am looking for is to change the color of select columns of a table as displayed in a PDM diagram. It is possible to do this from the UI, by clicking on a column of a table to select it in a diagram, then right-click to display a context menu, then select 'Sub-Objects Format'.

user3248578
  • 905
  • 8
  • 18
  • You mean changing the color of the text for one column? I saved a PDM as an XML file, and it pointed me to the ObjectCompositeSymbol.SubObjects attribute. – pascal Apr 30 '21 at 19:57
  • Thanks, @pascal but I was looking for VBA code. Which object is the ObjectCompositeSymbol attribute available on? – user3248578 May 01 '21 at 08:34
  • I was looking in the PD OLE Help. I guess, the Table symbol is derived from ObjectCompositeSymbol; I'm not sure how else, but you can enumerate the Symbols from the Diagram, and from a Table itself; also from a TableSymbol, you can use to Object to verify the object associated with the symbol... – pascal May 01 '21 at 09:51

1 Answers1

1

Here is an example, which does that with some arbitrary criteria to write in red some Columns in a Physical Data Model, when their name contains a "b"... using the ObjectCompositeSymbol.SubObjects attribute.

option explicit
const workfont = "Arial,8,N,255,0,0"
dim diags: set diags = createobject("Scripting.Dictionary")
dim m : set m = activemodel
dim t
for each t in m.tables
   ' public name of subobjects: Column; 0: display all
   dim sb : sb = "Column 0" + vbcrlf
   dim c,some : some = false
   for each c in t.columns
      ' our criteria is: column name contains a b
      dim match : match = instr(lcase(c.name),"b") <> 0
      if match then
         sb = sb + "{"+ c.GetAttribute("ObjectID")+"} " + workfont + vbcrlf
         some = true
      end if
   next
   if not some then sb = ""
   ' apply subobjects coloring
   dim s
   for each s in t.symbols
      if s.subobjects <> sb then
         s.subobjects = sb
         if not diags.exists(s.diagram) then diags.add s.diagram,0
      end if
   next
next
if diags.count > 0 then
   dim d
   for each d in diags.keys
      output "... redraw "+d.name
      d.RedrawAllViews
   next
end if

Result after script execution

pascal
  • 3,287
  • 1
  • 17
  • 35