博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PowerDesigner中批量替换name和code的脚本
阅读量:6948 次
发布时间:2019-06-27

本文共 1511 字,大约阅读时间需要 5 分钟。

无论是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  

转载于:https://www.cnblogs.com/mol1995/p/7145531.html

你可能感兴趣的文章
paoding-rose 之 maven配置
查看>>
Prometheus TSDB分析
查看>>
JavaScript系列:函数式编程(开篇)
查看>>
Ural 1018 (树形DP+背包+优化)
查看>>
ZOJ 3626(树形DP+背包+边cost)
查看>>
入驻博客园了
查看>>
Map集合
查看>>
poj 2663 Tri Tiling (状压dp+多米诺骨牌问题+滚动数组反思)
查看>>
Linux 小知识翻译 - 「BitTorrent」
查看>>
spark java api数据分析实战
查看>>
计算机学院大学生程序设计竞赛(2015’12) 1001 The Country List
查看>>
CodeForces 689E Mike and Geometry Problem
查看>>
Netty是什么?
查看>>
Java Web学习笔记--JSP for循环
查看>>
Windows Server 2012 R2 里面如何安装Net Framework 3.5
查看>>
ERROR 1366 (HY000): Incorrect string value:MySQL数据库、表的字符集为GBK
查看>>
Linux系统安装过程
查看>>
css flex布局
查看>>
如何高效完成英文文献翻译
查看>>
Unity 射线 Ray
查看>>