powerdesigner自动将name填充到注释的脚本
我在建模的时候,希望在生成脚本的时候有注释,所以才会看到Comment列,实际上,只要你的表中的Name列不为空,运行下面的VBScript,PD会帮你自动填充注释的Comment列值。
1 '把pd中那么name想自动添加到comment里面 2 '如果comment为空,则填入name;如果不为空,则保留不变,这样可以避免已有的注释丢失. 3 4 Option Explicit 5 6 ValidationMode = True 7 8 InteractiveMode = im_Batch 9 10 11 12 Dim mdl ' the current model 13 14 15 16 ' get the current active model 17 18 Set mdl = ActiveModel 19 20 If (mdl Is Nothing) Then 21 22 MsgBox "There is no current Model " 23 24 ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then 25 26 MsgBox "The current model is not an Physical Data model. " 27 28 Else 29 30 ProcessFolder mdl 31 32 End If 33 34 35 36 ' This routine copy name into comment for each table, each column and each view 37 38 ' of the current folder 39 40 Private sub ProcessFolder(folder) 41 42 Dim Tab 'running table 43 44 for each Tab in folder.tables 45 46 if not tab.isShortcut then 47 48 if trim(tab.comment)="" then '如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面. 49 50 tab.comment = tab.name 51 52 end if 53 54 Dim col ' running column 55 56 for each col in tab.columns 57 58 if trim(col.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避免已有注释丢失. 59 60 col.comment= col.name 61 62 end if 63 64 next 65 66 end if 67 68 next 69 70 71 72 Dim view 'running view 73 74 for each view in folder.Views 75 76 if not view.isShortcut and trim(view.comment)="" then 77 78 view.comment = view.name 79 80 end if 81 82 next 83 84 85 86 ' go into the sub-packages 87 88 Dim f ' running folder 89 90 For Each f In folder.Packages 91 92 if not f.IsShortcut then 93 94 ProcessFolder f 95 96 end if 97 98 Next 99 100 end sub
打开运行脚本的界面(Crtl+Shift+X),输入脚本,运行后注释的值就会自动的帮你填充好。
到此,PD添加共用字段和自动添加注释的方法结束了。