powerdesigner反向生成er图后中文注释调整

生成ER图之后,一般是这样的,很简单的表名、字段值、字符类型,但是事实上这样很蠢,没有注释的话完全没有办法给别人看嘛!要是给领导看,怕是要被当场打死。

 

 

 所以要加注释,加注释需要一个脚本,脚本我已经传到CSDN资源了,这里是连接http://download.csdn.net/download/qq_17010367/10232686。

 执行脚本,Tools——Execute Commands——Edit/Run Script ,在下面的弹出框中,红色框内是选择文件路径按钮,选择后点击“Run”,然后就变成了下面的样子……

 

 

 是不是很惊呆,卧槽我的字段呢?!不要急,来,让我们慢慢操作一波。Tools——Display perferences,下面说起来爱繁琐,我就不断截图了,红色框内表示要点击的地方,数字表示顺序。

 

3. 显示字段名

虽然注释显示出来了,但原字段不见了

如图点击

然后就可以了

 

补充:如果生成的图如下,字段在最后选项调整位置的话

到上一步显示Code的地方,如图圈中的工具挪动位置就可以了

 

 

 最后的效果如下:

 

 如果想给表名加注释的话,双击表名,编辑即可。

附:转换脚本

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
 
附:默认所有表都选中,点击选择旁边小按钮,取消反选、

完整步骤见

https://blog.csdn.net/weixin_42195284/article/details/102853438

posted @ 2020-05-06 21:57  keeperForever  阅读(653)  评论(0编辑  收藏  举报