PowerDesigner 显示 Comment 注释

原文在 这里,下面是简略版的说明,详情看原文。

  1. 双击任意表,在 Columns 标签中增加 Comment

  2. Tools > Display Perferences(显示首选项) > General Settings > Table > Advanced > Form > Columns > List columns > Select
    按顺序选择一下属性

    • Code
    • DataType
    • DataType(Domain or Data type)
    • Name
    • Key Indicator
    • Index Indicator
    • Null Status
  3. Tools > Execute Commands > Edit/Run Scripts (Ctrl + Shift + X),执行下面的 VBS 脚本。

    稍微修改了点:始终显示表的英文名;备注为空时显示列名。

    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 able
    
        For Each Tab In folder.tables
            If Not tab.isShortcut Then
                tab.name = tab.code + " " + tab.comment
                Dim col ' running column
    
                For Each col In tab.columns
    
                    If col.Comment = "" Or Replace(col.Comment, " ", "") = "" Then
                        col.Name = col.Code
                    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