This is code sample for resetting fond, color.
' Create a PDM with table called Table_1. Add some columns. set one of them to be primary key.
Option Explicit
Dim tbl, TabSymbol, col, TabFonts,ColumnFonts, PrimaryKeyFonts
'-------------------------------------------------------------------------
'Set font for a table name
'Set font for a column in the table. The color setting is 250,50,150
'------------------------------------------------------------------------
TabFonts ="DISPNAME "+CStr(RGB(250,0,0))+" Arial,12 N"
ColumnFonts=" Arial,8,B,250,50,150"
PrimaryKeyFonts=" Harrington,8,B,250,250,150"
'-----------------------------------------------------------------------
'Traverse the whole PDM diagram. Set font for each table
' Traverse each table's symbol setting
'Initialize each table's SubObject(Column font).
For Each tbl In Activemodel.Tables
For Each TabSymbol In tbl.symbols
TabSymbol.SubObjects =""
' Set font and color for each table.
'If tbl.name="Table_1" Then
'TabSymbol.FillColor=Cstr(RGB(20, 120, 100))
'TabSymbol.FontList= TabFonts
'Else
'TabSymol.FillColor=Cstr(RGB(200,100,20))
'End If
'Table background color
TabSymbol.FillColor=Cstr(RGB(0, 100, 0))
TabSymbol.FontList=TabFonts
'Set column font
For Each col In tbl.Columns
'Again initialize sub object.Just give it a name
If TabSymbol.SubObjects = "" Then
TabSymbol.Subobjects ="Column Font "
End If
'If a column is a primary key, set to different font
If col.Primary=True Then
TabSymbol.SubObjects = TabSymbol.SubObjects & vbCrLf & col.ObjectID & PrimaryKeyFonts
Else
TabSymbol.SubObjects = TabSymbol.SubObjects & vbCrLf & col.ObjectID & ColumnFonts
End If
Next
Next
Next
ActiveDiagram.RedrawAllViews()
Hi,
I am afraid, that you`ll have to create your own script, which will modify appropriate properties of class symbol. If you need to modify the format of class name (based on the Abstract property for instance), you will have to modify the FontList property of the classSymbol object of your class. See QDNM row in my output window. There is "I" at the end of the row, which means, that qualified name of the object is displayed in Italic. The bad news here is that FontList property contains unstructured text, so best approach here is IMHO using regular expression to find appropriate row in FontList property and modify it according to your needs.
Regarding the class attributes (operations, etc.), the situation is even a little bit more complicated. As you can see from my screenshot, there are 4 attributes in the class, but only 3 of them are displayed in the output window. It means, that when the format of the attribute in the class symbol is set to default, it is not present in the SubObjects property at all! So your script will have to first find out, whether the format of your attribute is modified (=its object ID will be present in the SubObjects property), and you can use regular expression to modify it. If the attribute format will be in default, you will have to add it manually to the SubObjects property. It is a very nasty way how to achieve your goal, but I am afraid, that it is the only one.
After you are done, you can put this algorithm to the class event handler for instance, which will make sure, that the formatting changes automatically each time, you make change in your object. Please see the code from my screenshot below, so you can better get to the properties desired.
HTH,
Ondrej
For each c in activemodel.classes output c.name For each ca in c.attributes output ca.Name Next output "----" For each cs in c.Symbols output cs.FontList output "----" output cs.SubObjects Next Next
Add comment