Script Structure

A generative script is written in text format and is organized in blocks consisting of related sets of statements. 
A block consists of an instruction designed to create an object followed by a set of statements surrounded by braces ({ }).  Statement blocks can be nested and the most enclosing one within a script corresponds to the document creation.  

A document is made up of a hierarchy containing objects, their properties and the features they own. A generative script reflects this object hierarchy. In the outermost statement block, you must create the document intended to contain all the features to be created later on.

Example 1

Please find below the basic structure of a script. You can create this skeleton by using the File > New > CATPart document command of the Script Editor:

part isa CATPart
{
           Mypart isa Part
           {
                PartBody isa BodyFeature
                      {
                      }
           }
}

 Example 2 

MyDocument  isa CATPart   // Creates a CATPart document
{
    MyPart isa Part
    {
        L = 30.0;
        PartBody isa BodyFeature  // Creates the main body
        {
            Length = 100.0; // Length is a parameter of the part
            Cyl isa Cylinder
           {
             cylinderLength = 20.0;
            }
            Base isa Cylinder // Base is an instance of Cylinder owned by MyPart
            {
                Height = ?Length * 2; // a formula property using MyPart/Length;
            }
        }
    }
}

 

For more information about the isa keyword and the ? operator, see isa keyword and ? operator.