on 10-08-2014 1:25 PM
Hi All
I found there is a function for retrieving the specific object collection from the Model
Dim Mdl As PdCommon.BaseModel
Set PD = CreateObject("PowerDesigner.Application")
PD.OpenModel ("D:\PowerDesigner\project.pdm"
For Each Mdl In PD.Models
Debug.Print Mdl.Name
Set ObjTab = Mdl.GetCollectionByName("Tables")
next
Is there is any function to get the specific object from the collection than iterating through the collection . For example . I want to get the emnployee table from the ObjTab collection
Set emptab =ObjTab .<<< functionname >>("Employee")
I tried GetCollectionByName , but its not working
Thanks for help
Ani
Hi,
You can use the "FindChildByName" or "FindChildByCode" functions.
Marc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ani,
To use the functions that Marc and Dirk mentioned you need to provide other required values for the functions´ parameter.
Just to give you an example on how to use the function FindChildByName, let´s say you have a Physical Model (PDM). This type of model has a collection of tables, so to find a specific table using the function FindChildByName your lines of code should be:
dim tabObj
set tabObj = activeModel.FindChildByName("Employee", PdPDM.cls_table, "",Nothing, False, False)
activeModel - represents you currently opened PDM model in the example I provide here.
Using the metamodel do a search for FindChildByName. This function has an explanation about all parameters it has, what they mean and what are their default value (if it applies).
Hope it helps.
Regards
-Paulo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Paulo
I am using the PD 15.x . I can not find the FindChildByName function in 15 . I tried below code . But shows error like the Object does not contains this property or method
Sub DoStuff()
Dim PD As PdCommon.Application
Dim Mdl As PdCommon.BaseModel
Set PD = CreateObject("PowerDesigner.Application")
PD.OpenModel ("D:\PowerDesigner\project.pdm")
Set tabObj = PD.ActiveModel.FindChildByName("Employee", PdPDM.cls_Table, "", Nothing, False, False)
end sub
Ani
Hi Ani,
Try the code below.
Dim PD As PdCommon.Application
Dim Mdl As PdPDM.Model
Dim Tbl As PdPDM.Table
Set PD = CreateObject("PowerDesigner.Application")
Set Mdl = PD.OpenModel("D:\PowerDesigner\project.pdm")
Set Tbl = Mdl.FindChildByName("Employee", PdPDM.cls_Table, "", Nothing, False, False)
If Not Tbl Is Nothing Then
PD.Output Tbl.Code 'check the result in PD´s output window
End If
Check if your model is located in your "D\PowerDesigner" directory.
You said that you could not find the function in PD 15.x, maybe it became available in a newest PD version than one you are using. I know that in PD 12.5 that function does not exist.
I checked my old PD versions and the 15.2.x.x.x I have here, does have the function available.
HTH,
-Paulo
User | Count |
---|---|
81 | |
10 | |
10 | |
8 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.