ModelRight Home
<% currentPage="resources" %>
<% currentItem="scripting" %>

ModelRight Scripting Guide - Introduction

Contents

On this page

  • Introduction
  • Orientation to ModelRight programmability
    • What there is to know

Subsequent pages

Getting started with ModelRight scripting

  • Choice of two programmability approaches
    • Built-in VBScript scripting environment
    • Automation using external programs
  • What ModelRight features can be programmed?
    • Accessing and navigating ModelRight's objects
  • ModelRight's programming UI and "Hello world" example
    • Script Explorer
    • Creating and saving a script
    • Script Editor

ModelRight's Object Model: Background

  • Background on ModelRight's Object Model
    • A database model as captured in MRObjects
    • Sample VBScript code to navigate the model
    • Completing your understanding of the structure of ModelRight's data

ModelRight's Model Explorer and Browsers

  • Overview of ModelRight's Explorer and Browsers
  • Comparison or Model Explorer and Browsers
  • Model Explorer View
  • Model Browser View
  • Metamodel Browser View
  • Tips

Some ModelRight Programming Topics in more Detail

  • Accessing MRObject Properties
    • Read a Property
    • Write a Property
    • Reading/Setting Properties of various datatypes
    • Reading and writing a Property which holds a Point datatype value
    • Special case: SetDataType
  • Transactions
  • VB Scripts and the User Interface
    • Prompting or getting input from the user

Sample ModelRight Scripts

  • Script Samples Introduction
    • Sample Model
    • Visual Basic Script documentation
  • Navigating and "dumping" a Database Model
  • Modifying a database model
  • Manipulating ModelRight "Graphics": visibility and style properties

Sample ModelRight COM Automation

  • COM Automation Introduction
  • Preparation to use ModelRight automation
  • Automation using Excel as the Automation client
  • Navigating and "dumping" a Database Model using COM Automation
    • Preparation
    • Sample Code
    • Notes

ModelRight Object Model (Classes) Reference

  • List of all ModelRight objects (classes) and their properties with notes.

Introduction

The ModelRight program provides a comprehensive environment for viewing, creating and editing database models as Entity-Relationship diagrams, and for forward and reverse engineering databases hosted by DBMSs from different vendors. ModelRight provides considerable power over the models themselves and also an unusual level of control over the graphical appearance of the models, including the capability to add annotations and control text and graphic style features.

To this foundation ModelRight adds scripting features through which to access and manipulate both the database model and the diagram graphic appearance in powerful ways.  For example:

  •  ModelRight's built-in forward engineering capabilities call provided scripts to produce vendor-specific SQL DDL statements. You can modify these SQL-generating scripts to suit your own workflow purposes, different dialects of SQL and so on.
  • You can develop macros to modify database models to suit your processes. You might use macros to automatically add standard fields to each table, or to consistently change field types to a new standard.
  • You can create macros to modify the visual appearance of a model view: For example to highlight some particular fields, or to hide standard housekeeping fields (like LastEditDate).
  • You might develop scripts to interrogate ModelRight models as part of a process to automatically generate application code from database structure.
  • After reverse engineering a model from a database that lacks relationships, your might used code to add knowledge from the application code (or from inspection of indexes) to add relationships and thereby greatly improve the understandability of the model and the application. This scenario occurs often with web applications and MySQL, for example.

Orientation to ModelRight programmability

What there is to know

To master ModelRight programmability, there are two main themes to tackle:

  • What kinds of code do you write to interact with ModelRight's world? 

    ModelRight offers a choice from two programmability approaches:
    • Built-in VBScript environment which runs within the ModelRight environment
      • You might want to modify or inspect the supplied scripts that ModelRight uses for forward engineering.
      • Add your own scripts to be called while running ModelRight.
    • COM Automation interface to ModelRight model files. You create an external application (in almost any language), which, using the ModelRight automation DLL, can read and write ModelRight model files.
       
  • What ModelRight features can your code interact with?
     
    • ModelRight exposes all aspects of its model data:
      • database model features such as tables, columns and all their properties, and also...
      • the visual aspects ("graphics") of ModelRight diagrams. 
    • ModelRight does not expose an automation interface for operating the ModelRight application itself (unlike Microsoft Office applications such as Word or Excel).

Much of what you need to know involves understanding the conceptual layout of the tree of ModelRight objects, and then knowing the programming aspects of accessing these objects.  These topics are described on subsequent pages.

Original article by Graham Wideman