PowerDesigner反向工程并且生成说明文档(详细版)

网上资料很多,也很乱,以前自己也写过,太简单了,真的没想到10年了,PDM居然还是很受欢迎. 这里自己再总结一下

1:下载和安装PowerDesigner 这里省略 

2: 打开PowerDesigner  ->File -> New Model -> Model types ->  Physical Data Model 

3: 选中 PhysicalDiagram_1   ,再选择Database  ->Update Model from Database

4:安顺序新建一个连接数据库源,这里的示例是 Sql server 其它的也差不多

 

 

 

 5:选择之前添加的数据源

 

 

 6:然后等待生成 

7:  然后你会发现备注没有8L出来...

8:添加备注的办法

选中Comment 并确定

 

 

然后再详情页就出来了,那么在Diagram中还是没有显示出来 ,点击Tools ,然后选择“”显示首选项“ Displat Prederences”

 选择table ,再选择 Advanced,在选择Culumns,在选择放大镜符号 

可以上下调动,并且勾选你要的 ,我这里只要 Code ,Name,Data Type

然后引用网上的脚本,来把name 和 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 ->执行语句  

 

执行完以后你会发现已经OK了,那么生剩下来的就是导出HTML或者WORD了

9:导出说明文档

 

 选择  那个绿色的图标 new Reoirt 

10:删掉不需要的东西  ,只要这2个就可以了...可以根据自己的需求增加或删除

 右键选择Layout ,然后设置 ,选择自己要显示的列,并且排序

 11:选择,并生成指定的文档,支持html 和 word 

12:选择生成地址后,生成后看效果 

 

当然里面还有很多细节,字体各种都可以这只,这里就不做介绍了

最后我发现,table 名称我希望包含 备注和 code,可以重新运行脚本

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.code + "  " + 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

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值