powerdesigner是个好东西,设计工作中经常有些工作需要批量执行修改,采用其自带的脚本语言是个不错的选则,下面这段脚本把pdm中所有对象并修改,其中包含对多层package中对象的调用,很方便
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
'ceaate by runnerrunning
' get the current active model
Dim mdl ' the current model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "There is no Active Model"
Else
ListObjects(mdl)
End If
'-----------------------------------------------------------------------------
Private Sub ListObjects(fldr) '列出所有的对象
output "Scanning " & fldr.code
Dim obj ' running object
For Each obj In fldr.children
' Calling sub procedure to print out information on the object
DescribeObject obj
TableSetComment obj
Next
' go into the sub-packages
Dim f ' running folder
For Each f In fldr.Packages '递归调用列出所有的对象
'calling sub procedure to scan children package
ListObjects f
Next
End Sub
'-----------------------------------------------------------------------------
' Sub procedure to print information on current object in output
'-----------------------------------------------------------------------------
Private Sub DescribeObject(CurrentObject)
if not CurrentObject.Iskindof(cls_NamedObject) then exit sub
output "Found "+CurrentObject.ClassName+" """+CurrentObject.Name+""", Created by "+CurrentObject.Creator+" On "+Cstr(CurrentObject.CreationDate)
End Sub
'ceaate by runnerrunning
Private Sub TableSetComment(CurrentObject)
if not CurrentObject.Iskindof(cls_Table) then exit sub
'output "Found "+CurrentObject.ClassName+" """+CurrentObject.Name+""", Created by "+CurrentObject.Creator+" On "+Cstr(CurrentObject.CreationDate)
if not CurrentObject.isShortcut then
CurrentObject.Comment = CurrentObject.name &vbCrLf& CurrentObject.Comment
Dim col ' running column
for each col in CurrentObject.columns
col.Comment = col.name &vbCrLf& col.Comment
next
end if
End Sub
//本人原创runnerrunning@163.com转载请保留本信息
//http://blog.csdn.net/runnerrunning
//大家看了别忘了点右边的广告阿支持一下runnerrunning@163.com阿