TMS Data Modeler Tools / Scripting button - documentation and/or examples

What kind of customization can be done through the scripting IDE under Tools / Scripting?
Which classes &/or objects can we access from it?
I found no documentation about it, just this paragraph :

Version 3.3 (Dec-2018)
· New: "Scripting" button in Tools tab in ribbon, opens a full scripting IDE
for low-level and advanced manipulation of the existing data

What exactly is it intended for? Could you publish some examples?

For now it's being mostly used for support. From there you can manipulate the Data Modeler model, to do some operations in your project.
The main object is Dic, which holds all the information about the project. For example, the following script:

  I, J: Integer;
  Fld: TGDAOField;
  RequiredBefore: Boolean; 
  for I := 0 to Dic.Tables.Count - 1 do     
    for J := 0 to Dic.Tables[I].Fields.Count - 1 do
      Fld := Dic.Tables[I].Fields[J];               
      if (Fld.Domain <> nil) and not Fld.InPrimaryKey then       
        Fld.RequiredSpecific := True;
        if Fld.Required = Fld.Domain.Required then
          Fld.RequiredSpecific := False;

Will add an underscore (_) in front of all table names. Again, this is mostly for support, as modifying the project directly might have side effects. For example, for the simple script above, the user interface will not be updated, so you have to save the project, and reopen again to see the changes.

Instead of the underscore in table names, this script seems to correct RequiredSpecif property for fields mapped to a domain; I believe to be used after some manual domain change.

Now I understand it's use.
Maybe it could have helped when I needed to change a whole project from autoinc fields to uuid fields, and also when I had to change the same project from UUID(32) to SmartGUID, which uses (38). I had to modify all relations and PKs one by one, as there's no way to change a domain when it's already used in relations.

Can we have a list of all classes (like TGDAOField) and objects (like Dic) published to the scripting engine?

1 Like

Yes, in the end I pasted the wrong script. Sorry about that, but you got the idea.
Unfortunately there is no documentation about the classes published to scripter, but the code completion can give you a good idea.

Almost everything is under the Dic variable, so typing Dic. and using code completion you will see what's there, mostly.

1 Like

How can we tell when the scripts are executed?
Are there any specially named events or methods one should declare?

For example, it's meant to access a table's constraints collection, but if I run this simple script


it always shows '0' (zero), even if this table has some FK constraints that are generated by data modeler.

Constraints are just for check constraints. The FK constraints are listed globally for the whole database, using the Dic.Relationships property.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.