powerdesign中逆向工程后name和comment的互换

  powerdesign 中,将数据库中可以逆向生成pdm的结构图,比较清晰看到系统的结构,
但假如是db先行的话,一般是db中的每个列中用comment中文注释说明这列是
干什么的,但逆向工程后,会发现pd中的name和code都变成中文,
其中我们期望的是name是中文,code是英文(就是db中的列),那么我们其实
可以将db中的comment跟name进行一个复制,把comment中的内容都全部复制到
name中去就可以了,网上找到这个VBS脚本,原来pd中的也可以用VBS对PD的对象进行编程的,

VBS脚本如下:

Option Explicit
ValidationMode = True
InteractiveMode = im_Batch

Dim mdl 


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)
   Dim Tab
   for each Tab in folder.tables
      if not tab.isShortcut then
         if (not isnull(tab.comment)) and (trim(tab.comment)<>"") then
            tab.name = tab.comment
         end if
         Dim col 
         for each col in tab.columns
         if (not isnull(col.comment)) and  (trim(col.comment)<>"")   then
            col.name= col.comment
         end if
         next
      end if
   next

   Dim view
   for each view in folder.Views
      if not view.isShortcut then
         if (not isnull(view.comment)) and (trim(view.comment)<>"") then
            view.name = view.comment
         end if
      end if
   next

   
end sub


  在tools-execute command-run script中输入上面的脚本就可以运行了,十分方便。

  当然,在db中加上comments是个良好的习惯。

猜你喜欢

转载自jackyrong.iteye.com/blog/1874550