1. 程式人生 > >PowerDesigner顯示Comment註釋

PowerDesigner顯示Comment註釋

PowerDesigner預設顯示的列是Name及型別,如下圖示:


現在需要顯示註釋列,以便使得ER圖更加清晰。但是PowerDesigner勾選Comment顯示沒有效果,所以通過以下幾步來處理:

雙擊表,彈出表屬性對話方塊,切到ColumnTab,預設是沒顯示Comment的,顯示Comment列,這麼做

設定顯示Comment

有了Comment列,並補充Comment資訊


確定儲存,開啟選單 Tools>Display Perferences..

調整顯示的Attribute


OK,儲存,確定,退出設定頁,應用到所有標識,可以看到表變化

接下來需要執行VBS指令碼,借鑑網路上的指令碼,並且完善了下,處理Comment為空的情形

    Option   Explicit   
    ValidationMode   =   True   
    InteractiveMode   =   im_Batch
    Dim blankStr
    blankStr   =   Space(1)
    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 = "" or replace(col.comment," ", "")="" Then
                            col.name = blankStr
                            blankStr = blankStr & Space(1)
                      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  
開啟選單Tools>Execute Commands>Edit/Run Script.. 或者用快捷鍵 Ctrl+Shift+X

執行完,可以看到第3列顯示備註哈哈,效果如下

原理就是把顯示name的列的值,替換成註釋的值,所以下次如果調整comment,還有重新執行指令碼,所以最好放在最後執行。