1、根据条件更改字符类型.vbs
Option Explicit ValidationMode = True InteractiveMode = im_Batch 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 'This routine copy name into code for each table, each column 'of the current folder Private sub ProcessFolder(folder) 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 col.name= MID(col.comment,instr(col.comment,"-")+1) '列的名字取自注释中“-“的后半部分 if instr(col.comment,"所得")<>0 then col.DataType= "VARCHAR2(10000)" '注释中包含“所得”字样的,其对应列的数据类型置为"VARCHAR2(10000)" end if next end if next end sub
2、列的字符类型及名称更改.vbs
Option Explicit ValidationMode = True InteractiveMode = im_Batch 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 'This routine copy name into code for each table, each column and each view 'of the current folder Private sub ProcessFolder(folder) 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 col.name= MID(col.comment,instr(col.comment,"-")+1) '列的名字取自注释中“-“的后半部分 if instr(col.comment,"财产")<>0 then '注释中包含“财产”字样的,其对应列的数据类型置为"NUMBER(22,2)" col.DataType="NUMBER(22,2)" end if if instr(col.comment,"流转")<>0 then '注释中包含“流转”字样的,其对应列的数据类型置为"NUMBER(28,6)" col.DataType="NUMBER(28,6)" 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
3、根据条件进行Domain关联.vbs
Option Explicit ValidationMode = True InteractiveMode = im_Batch 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 'This routine copy name into code for each table, each column 'of the current folder Private sub ProcessFolder(folder) 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 'col.name= MID(col.comment,instr(col.comment,"-")+1) '列的名字取自注释中“-“的后半部分 if instr(col.comment,"财产")<>0 then '根据具体需要,设定需要更改Domain的列的条件 dim thisdomain,i i=0 for each thisdomain in folder.domains if i=2 then '根据具体需要,修改第?个Domain(0、1、2...) col.domain = thisdomain Exit for end if i=i+1 next end if next end if next end sub
4、说明
前两个实际内容差不多,只不过一个更简化一些;第三个对于PowerDesigner实际建模意义重大。
对于第三个VB脚本中,“if i=2 then '根据具体需要,修改第?个Domain(0、1、2...)”,i从0开始,其循环的规则是按Domain的PhysicalDomain Id排序;PhysicalDomain Id的查看方式是用UltraEdit打开物理模型,然后搜索“PhysicalDomain Id”即可查看。