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
dictionary.

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:

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

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?
Thanks.

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