Toad World® Forums

Create objects in TDM model from a script


I want to write a script to automate the creation of domains (by getting them from our Oracle Designer). Where can I find the information to create new objects from a script?



Unfortunately, there is not a complete documentation on this issue.
Current sources of information:

Anyway, please find attached a script for you. (I will also publish it in the Sample Script section then - for other users.)

Notes on the attached script:

var Model = app.Models.GetObject(0);
… the parameter in GetObject determines here with which model the script should work. 0 is the first model listed in the Application View. 1 is the second model listed in the Application View etc.

2006 is an domain object type. You can find out object types in metamodel of the database you work with.

  1. Open your model.

  2. Select a package of your database (e.g. Database Oracle package) in Package Explorer (Tools menu).

  3. Right-click the Database Oracle package | Open Metamodel.

  4. Find a class in metamodel (Model menu | Classes). For a domain, it will be class PERDomain or “PERDomainOR”.

  5. See the Object Type. (Also when double-click the PERDomain/PERDomainOR class to open its properties dialog. On tab General, you can see the Object Type.)

GUIDs of data types can be found:

  • in package DatabaseOracle10g.txg (for Oracle 10g db)
  • you can see them in a script for reverse engineering, which is a script “RE Oracle 10g” (for Oracle 10g db). Please see the GetDataType function in the script.

How to Execute Script:

  1. Unzip the attachment.
  2. Open it e.g. in Notepad.
  3. Copy and paste the script in the Scripting Window in TDM3. (Tools | Scripting Window).
  4. Run the script. (See the Execute button in the Scripting Window toolbar.)

Well, I hope this will help.


Vladka + Mario (463 Bytes)


Just a quick update:
The “Add Domain Object” script and a new “Add Entity Object” script are available at:

The scripts were written for Oracle models, however you can modify them for your database. Please read the notes in the script description section. Thanks.


Vladka + Mario