PowerDesigner配置显示注释comment配置方法

2021/04/05

以下文章来源于小小叔

正文

目前我我用的是15版本制作ER图,相近的版本应该功能差异都不会太大下面来说说制作过程中遇到的几个问题:

问题之一我们建完第一张表会发现我们的表中的name字段值并不能生成comment的字段注释:

虽然可以自己手动将注释手动添加到comment字段但是这样觉得效率太慢了,那么下面就讲讲如何高效的将注释映射到comment里面

1.首先找到工具的如下位置

2.找到如下位置,按步骤一次进入

3.接下来将这个comment勾选

ok之后点击ok保存

4.接下来找到如下位置

5.调出执行命令的接口

注意:我的是有name属性值而没有comment所以执行以下脚本,如果是有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
'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view
'   of   the   current   folder
Private   sub   ProcessFolder(folder)
Dim   Tab   'running     table
for   each   Tab   in   folder.tables
if   not   tab.isShortcut   then
tab.comment   =   tab.name
Dim   col   '   running   column
for   each   col   in   tab.columns
col.comment=   col.name
next
end   if
next
Dim   view   'running   view
for   each   view   in   folder.Views
if   not   view.isShortcut   then
view.comment   =   view.name
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

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

接下来将脚本复制到刚刚打开的窗口中

两个脚本不一定都要执行看看你是哪个字段没有值就执行哪个替换,然后就ok了看一下效果

完美!!!

Post Directory