PowerDesigner脚本:删除无用的Data Items

80酷酷网    80kuku.com

  脚本
'*****************************************************************************
'文件:Delete useless data items.vbs
'版本:1.0
'版权:floodzhu (floodzhuhotmail.com),2005.1.6
'功能:遍历概念模型,把无用的Data Items删除。
'*****************************************************************************
dim index
index = 0

dim model 'current model
set model = ActiveModel


If (model Is Nothing) Then
   MsgBox "当前没有活动的模型。"
ElseIf Not model.IsKindOf(PdCDM.cls_Model) Then
   MsgBox "当前模型不是概念模型。"
Else
   View model
   MsgBox index & "个无用字段被删除。"
End If

'*****************************************************************************
'函数:View
'功能:递归遍历
'*****************************************************************************
sub View(folder)
   dim item
   for each item in folder.DataItems
      if not item.IsShortCut then
         Visit item
      end if
   next
  
   '对子目录进行递归
   dim subFolder
   for each subFolder in folder.Packages
      View subFolder
   next
end sub

'*****************************************************************************
'函数:Visit
'功能:处理节点
'*****************************************************************************
sub Visit(node)
 if node.UsedBy="" then
      node.delete
      index = index + 1
   end if
end sub



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: