虽然网上有很多这方面的教程,而且都可以用,但是使用后有一点让我不满意,就是会把最上面的表名称也变成表注释
最开始的样子:
找到网上的教程,走下来变成了这样子(可以看到最上面的表名都变成了表注释了):
但是我不想最上面的表名变成注释,于是又去看别人的博客、教程等等....无果(都是复制粘贴 - -!)....
最后快放弃的时候,还是让自己看了一下最核心的那部分VB代码(后面会放出来),看看能不能自己做一点修改,,,看完之后才发现居然那么简单,为啥不早点看代码.......就只需要吧下面这段代码注释就好了........
先说一下设置Table显示注释在Tools -> Display Preferences -> Table中可以设置
按理来说把表字段注释显示出来应该是在哪里设置一下就可以解决的事情。。没想到如此强大的PowerDesigner没有这功能。。。
设置字段显示那些列也是有设置的:
也不知道哪位大神想出了这个投机取巧的方法:既然没有Comment(注释)属性,但是有其他属性,那么我们可以把Comment的值赋给其他属性,然后把其他属性显示在Table框中,这样不就好了!
下面是现实步骤
1、 设置Table显示哪些属性
2、执行VB脚本将Comment属性值赋值到Name属性上
将以下脚本代码复制到其中执行
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim mdl ' the current model
' get the current active model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "There is no current Model "
ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
MsgBox "The current model is not an Physical Data model. "
Else
ProcessFolder mdl
End If
Private sub ProcessFolder(folder)
On Error Resume Next
Dim Tab 'running table
for each Tab in folder.tables
if not tab.isShortcut then
' 如果不想最上面显示表名也变成注释的话就将下面这行代码注释
tab.name = tab.comment
Dim col ' running column
for each col in tab.columns
if col.comment="" then
else
col.name= col.comment
end if
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.name = view.comment
end if
next
' go into the sub-packages
Dim f ' running folder
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub
最后需要注意的是,执行脚本只是将Comment属性值赋值到Name属性上面,并不代表Comment属性值有变化的时候Name会跟着变化,所以如果Comment值有变化的时候,还需要重新刷一下上面的脚本