• [原创]通过编写PowerDesigner脚本功能批量修改属性


    在设计的时候经常会碰到注释和Name不统一,需要手工复制的问题。其实PD提供了很好的方法可以批量进行调整。

    我写了一个递归的修改方法,如下所示:可做为参考。
     1 '******************************************************************************
     2 '* File:     CommentVsName.vbs
     3 '* Purpose:  把字段及表注释为空的用name来代替
     4 '* Title:    保证每个字段及表都有注释
     5 '* Category: 注释
     6 '* Author:   lbq(buddy) liubiqu@sina.com
     7 '* Created:  2008年3月24日
     8 '* Modified: 2008年4月24日
     9 '* Use:      打开PDM,运行本脚本(Ctrl+Shift+X)
    10 '* Version:  1.0
    11 '* Comment:  遍历PDM中的所有包,把数据表及字段的注释为空的部分用Name来替换
    12 '* Copyright (C) 2008 topsthink Inc.
    13 '******************************************************************************
    14 
    15 Option Explicit
    16 ValidationMode = True
    17 InteractiveMode = im_Abort
    18 
    19 
    20 Dim mdl ' 定义当前的模型
    21 
    22 '通过全局参数获得当前的模型
    23 Set mdl = ActiveModel
    24 If (mdl Is NothingThen
    25    MsgBox "没有选择模型,请选择一个模型并打开."
    26 ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
    27    MsgBox "当前选择的不是一个物理模型(PDM)."
    28 Else
    29    ProcessFolder mdl
    30 End If
    31 
    32 
    33 '--------------------------------------------------------------------------------
    34 '功能函数
    35 '--------------------------------------------------------------------------------
    36 Private Sub ProcessFolder(folder)
    37    Dim Tab '定义数据表对象
    38    for each Tab in folder.tables
    39       if not tab.isShortcut then
    40          if tab.comment = "" then tab.comment = tab.name '进行判断并赋值
    41          Dim col '定义列对象
    42          for each col in tab.columns
    43             if col.comment = "" then col.comment = col.name '进行判断并赋值
    44          next
    45       end if
    46    next
    47    
    48    '对子包进行递归,如果不使用递归只能取到第一个模型图内的表
    49    dim subfolder
    50    for each subfolder in folder.Packages
    51       ProcessFolder subfolder
    52    next
    53 
    54    'msgbox "完成把comment为空的内容用name代替"
    55 End Sub


    [2008年5月1日]如果需要对name 进行赋值的时候可能会出现同名的错误,所以可以利用 VBS中的On Error Resume Next这个语句进行跳过。如
     1Private Sub ProcessFolder(folder)
     2   Dim Tab '定义数据表对象
     3   for each Tab in folder.tables
     4      if not tab.isShortcut then
     5         if tab.comment <> "" then tab.name = tab.comment&"(" &tab.name&")" '进行判断并赋值
     6         Dim col '定义列对象
     7         for each col in tab.columns
     8            if col.comment <> "" then 
     9               On Error Resume Next '增加此句
    10               col.name = col.comment '进行判断并赋值
    11            end if
    12         next
    13      end if
    14   next
  • 相关阅读:
    python编写规范
    我们分析了400位华语歌手的歌词,发现人们重点关注的人事物情
    外部厂商公开工具
    OSI七层与TCP/IP五层网络架构详解
    npm run dev--The 'mode' option has not been set, webpack will fallback to 'production' for this value
    webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
    PPTV(pplive)_forap_1084_9993.exe 木马清除经历
    【转】【Nginx】Nginx 入门教程 + 常用配置解析
    【转】【Python】Python 中文编码报错
    【Centos】systemd入门教程
  • 原文地址:https://www.cnblogs.com/liubiqu/p/1170108.html
Copyright © 2020-2023  润新知