無論是cdm還是pdm都可以批量替換、處理。可在Tool-Execute commands-Edit/Run script中編輯運行腳本:
下面的腳本是批量將CDM中實體的用Code替換掉Name
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim mdl '當前model
'獲取當前活動model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "There is no current Model "
ElseIf Not mdl.IsKindOf(PdCDM.cls_Model) Then '如果是處理pdm,這里換成PdPDM.cls_Model
MsgBox "The current model is not an Physical Data model. "
Else
ProcessFolder mdl
End If
' This routine copy name into comment for each table, each column and each view
' of the current folder
Private sub ProcessFolder(folder)
Dim item '要處理的對象
for each item in folder.Entities
if not item.isShortcut then '先處理每個實體或類的Name和Code
item.name = item.code
'再處理每個類的屬性
dim col
for each col in item.Attributes
col.name= col.code
next
end if
next
'最后處理關聯關系
for each item in folder.relationships
if not item.isShortcut then
item.name = item.code
end if
next
'遞歸遍歷子文件夾
Dim f '子文件夾
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub
////////////////////////////////////////////////////////////////////////////////////////////////////
此外,若是在pdm中可以用下面的方法遍歷表或視圖
Dim Tab 'running table
for each Tab in folder.tables
if not tab.isShortcut then
tab.name = tab.code
Dim col ' running column
for each col in tab.columns
col.name= col.code
next
end if
next
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
view.name = view.code
end if
next
//////////////////////////////////////////////////////////////////////////////////////
//遍歷Domian
For each dm in mdl.domains
If Not dm.isShortcut Then
If dm.code = "dm_pk" Then
Exit For
End If
End If
Next