问题描述
我可以使用 VBA 循环遍历表的列并更改与 Column 对象本身相关的许多属性。我正在寻找的是更改 PDM 图中显示的表的选择列的颜色。可以从 UI 执行此操作,方法是单击表格的列以在图表中选择它,然后右键单击以显示上下文菜单,然后选择“子对象格式”。
解决方法
这是一个示例,它使用一些任意条件将物理数据模型中的某些列写成红色,当它们的名称包含“b”时...使用 ObjectCompositeSymbol.SubObjects
属性。
option explicit
const workfont = "Arial,8,N,255,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