how to update name to comment in PDM

'******************************************************************************
'* File:     Comment2Name.vbs
'* Purpose:  把字段及表的name用comment来代替
'* Use:      打开PDM,运行本脚本(Ctrl+Shift+X)
'* Version:  1.0
'* Comment:  遍历PDM中的所有包,把数据表及字段的Name用comment来替换
'* Copyright (C) 2008 topsthink Inc.
'******************************************************************************

Option Explicit
ValidationMode = True
InteractiveMode = im_Abort
 
Dim mdl ' 定义当前的模型

'通过全局参数获得当前的模型
Set mdl = ActiveModel
If (mdl Is Nothing) Then
   MsgBox "没有选择模型,请选择一个模型并打开."
ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
   MsgBox "当前选择的不是一个物理模型(PDM)."
Else
   ProcessFolder mdl
End If
 
'--------------------------------------------------------------------------------
'功能函数
'--------------------------------------------------------------------------------
Private Sub ProcessFolder(folder)
   Dim Tab '定义数据表对象
   for each Tab in folder.tables
      if not tab.isShortcut then
         if tab.comment <> "" then tab.name = tab.comment&"(" &tab.name&")" '进行判断并赋值
         Dim col '定义列对象
         for each col in tab.columns
            if col.comment <> "" then
               On Error Resume Next '增加此句
               col.name = col.comment '进行判断并赋值
            end if
         next
      end if
   next
 
   '对子包进行递归,如果不使用递归只能取到第一个模型图内的表
   dim subfolder
   for each subfolder in folder.Packages
      ProcessFolder subfolder
   next
 
   'msgbox "完成把name用comment的内容name代替"
End Sub
This entry was posted in java. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">