PowerDesigner非常有用的两个VBScript
1、根据条件更改字符类型.vbs
Option ExplicitValidationMode = TrueInteractiveMode = im_BatchDim mdl 'the current model'get the current active modelSet mdl = ActiveModelIf (mdl Is Nothing) ThenMsgBox "There is no current Model"ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) ThenMsgBox "The current model is not an Physical Data model."ElseProcessFolder mdlEnd If'This routine copy name into code for each table, each column'of the current folderPrivate sub ProcessFolder(folder)Dim Tab 'running tablefor each Tab in folder.tablesif not tab.isShortcut thentab.name = tab.commentDim col 'running columnfor each col in tab.columnscol.name= MID(col.comment,instr(col.comment,"-")+1) '列的名字取自注释中“-“的后半部分if instr(col.comment,"所得")<>0 then col.DataType= "VARCHAR2(10000)" '注释中包含“所得”字样的,其对应列的数据类型置为"VARCHAR2(10000)"end ifnextend ifnextend sub
2、列的字符类型及名称更改.vbs
Option ExplicitValidationMode = TrueInteractiveMode = im_BatchDim mdl 'the current model'get the current active modelSet mdl = ActiveModelIf (mdl Is Nothing) ThenMsgBox "There is no current Model"ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) ThenMsgBox "The current model is not an Physical Data model."ElseProcessFolder mdlEnd If'This routine copy name into code for each table, each column and each view'of the current folderPrivate sub ProcessFolder(folder)Dim Tab 'running tablefor each Tab in folder.tablesif not tab.isShortcut thentab.name = tab.commentDim col 'running columnfor each col in tab.columnscol.name= MID(col.comment,instr(col.comment,"-")+1) '列的名字取自注释中“-“的后半部分if instr(col.comment,"财产")<>0 then '注释中包含“财产”字样的,其对应列的数据类型置为"NUMBER(22,2)" col.DataType="NUMBER(22,2)"end ifif instr(col.comment,"流转")<>0 then '注释中包含“流转”字样的,其对应列的数据类型置为"NUMBER(28,6)" col.DataType="NUMBER(28,6)"end ifnextend ifnextDim view 'running viewfor each view in folder.Viewsif not view.isShortcut thenview.name = view.commentend ifnext'go into the sub-packagesDim f 'running folderFor Each f In folder.Packagesif not f.IsShortcut thenProcessFolder fend ifNextend sub
3、根据条件进行Domain关联.vbs
Option ExplicitValidationMode = TrueInteractiveMode = im_BatchDim mdl 'the current model'get the current active modelSet mdl = ActiveModelIf (mdl Is Nothing) ThenMsgBox "There is no current Model"ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) ThenMsgBox "The current model is not an Physical Data model."ElseProcessFolder mdlEnd If'This routine copy name into code for each table, each column'of the current folderPrivate sub ProcessFolder(folder)Dim Tab 'running tablefor each Tab in folder.tablesif not tab.isShortcut thentab.name = tab.commentDim col 'running columnfor each col in tab.columns'col.name= MID(col.comment,instr(col.comment,"-")+1) '列的名字取自注释中“-“的后半部分if instr(col.comment,"财产")<>0 then '根据具体需要,设定需要更改Domain的列的条件dim thisdomain,ii=0for each thisdomain in folder.domainsif i=2 then '根据具体需要,修改第?个Domain(0、1、2...)col.domain = thisdomainExit forend ifi=i+1nextend ifnextend ifnextend sub
4、说明
前两个实际内容差不多,只不过一个更简化一些;第三个对于PowerDesigner实际建模意义重大。
对于第三个VB脚本中,“if i=2 then '根据具体需要,修改第?个Domain(0、1、2...)”,i从0开始,其循环的规则是按Domain的PhysicalDomain Id排序;PhysicalDomain Id的查看方式是用UltraEdit打开物理模型,然后搜索“PhysicalDomain Id”即可查看。