Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


TurboCAD 20 Users Guide Customized Programming
You can customize your TurboCAD application by recording and editing macros, and using the SDK. Macro Recorder

 

MacroRecorder Palette

Available in TurboCAD Pro and Platinum only

Menu: View / Tools | Palettes | MacroRecorder Palette

Creates and plays scripts - scenarios of creating objects and manipulating their properties. You can also record object transformation - move, copy, scale, and rotate. Scripts can be saved for future play.

Recording and Playing Scripts

To record a script, click Start Record in the MacroRecorder palette.

Image RemovedImage Added

Script Options:

  • Mouse Click: The script will include each mouse click, including work in the Inspector Bar, use of the local menu, etc.). A script created with mouse clicks can be used only in TurboCAD. A script that was created without mouse clicks can be used in any TurboCAD add-on, if the add-on is created based on the TurboCAD Object Model.

...

Image Removed
Note: A script that uses mouse clicks cannot close windows. For example, if a viewport creation is recorded, when this script is played, the Named View window must be closed manually.
Image Removed

...

  • Mouse Move: Available when recording mouse clicks, records all mouse moves as well. For example, if you record the creation of a circle using mouse moves, you are recording exactly how the cursor moves while sizing the circle. Without mouse moves, you will only record the end result of the circle. This option increases the size of the script, and results in slower playback. Mouse move recording is recommended for scripts in which exact mouse positioning is important, such as work in the Edit Tool.

To finish the script, click Stop Record. Image Removed

Image Added

...

Warning: Keep in mind that the script will only contain the actions performed after starting the script and before ending it. For example, you can record creating a line, stop the recorder and then change the line color. When you play the script, the line will have a different color because the script does not include the color change. Image Removed
 The

...

The script text will be displayed in the MacroRecorder palette. You can edit the script directly in the palette by placing the cursor on the desired line and changing text. You can play the script back by clicking Play Script.

Image RemovedImage Added Image Removed
Image Removed

If you clear all items from the screen, or open a new file, playing the script will create new objects on the screen. To save the script, click Save Script. Scripts are saved as *.tcr (TurboCAD Recorder) files.
Image Removed Image Added

You can play a saved script by clicking Open Script.

Image RemovedImage Added

Select the desired script, and it is loaded into the palette. Click Play Script to play it.

Sample Scripts

Several sample scripts are provided for you. Click Open Script.

Image RemovedImage Added

Set Files of type to VBS and browse to TurboCAD's installation folder. Browse to SDK \ Samples \ VBS \ WshScriptPack. This folder contains a few scripts you can run. Image Added

Image Removed
 Select Select the script you want to run and click Open. The script opens the Macro Recorder palette. (You can also open these files in a text editor.)

Image RemovedImage Added

 Click Click Play Script. Image Removed

Image Added

Some scripts give you messages related to what is found in your open files. The last script draws several 3D objects.

Script Limitations

Currently, some TurboCAD objects, such as images, cannot be used in scripts. Scripts record object creation only, and not all TurboCAD settings can be reproduced. For example, workplane position and views cannot be set in a script. Therefore, set the desired positions of the workplane and views before playing the script.

 

 

 

 

 

 

 

 

Parametric Part Manager
Available in TurboCAD Pro and Platinum only
Parametric parts (PPM) are defined using a text description (script). The script defines the structure, editable properties, and output that result in a parametrically editable part. The script must be saved with a *.PPM extension. The name of the file determines the name of the part.
Examining a Script
A simple example of a parametric part is a rectangle where the width, height and rotation angle are defined though parameters. The script of such part might look as follows:
// Here is a description of simple rectangle. H = Parameter("Height", 5, LINEAR, Interval(0, 100)); L = Parameter("Length", 10, LINEAR, Interval(0, 200)); Angle = Parameter("Angle", 0, ANGULAR, Interval(0, 360)); Rect1 = Rectangle(H, L); Rect = RotateZ(Rect1, Angle); Output(Rect);
Let's examine each line of this example:
LINE 1
// Here is a description of simple rectangle.
The '//' indicates a comment. Comments do not affect the behavior of a part. All text following '//' to the end of the line are contained by the comment.
LINE 2
H = Parameter("Height", 5, LINEAR, Interval(0, 100));
The second line specifies the definition of the 'H' parameter. Let's break out each element of the line to define its
function: H This is the identifier (name) of the parameter in the part description = The equals sign associates the identifier with its definition Parameter This is a function. 'Parameter' defines that H is a Parameter ( Specifies the start of the Parameter function's properties "Height" The name of the parameter that will appear in the Properties dialog , Indicates the end of one property and the beginning of the next 5 Assigns the default value for H , Separates properties LINEAR Specifies that H is a linear value , Separates properties Interval(0, 100) Specifies the allowable values for H as an interval from 0 to 100 ) Specifies the end of the Parameter function's properties ; End of definition for H
LINES 3 – 4
L = Parameter("Length", 10, LINEAR, Interval(0, 200)); Angle = Parameter("Angle", 0, ANGULAR, Interval(0, 360));
The next two lines in the example are similar to the previous one. They define the characteristics of L and Angle parameters in a similar layout. Note that the 'Angle' parameter uses an ANGULAR interval rather than LINEAR.
LINE 5
Rect1 = Rectangle(H, L);
This line uses the Rectangle function to define a rectangle called 'Rect1'. It uses the previously defined H and L parameters to specify its properties, height and length. The center of this rectangle will be at the world origin (x=0,y=0,z=0) in the drawing. More on the rectangle tool will be covered later.
LINE 6
Rect = RotateZ(Rect1, Angle);
This line defines a new rectangle called 'Rect' which is a rotated version of 'Rect1', using the Angle parameter to define the rotation.
LINE 7
Output(Rect);
The last line specifies that the output of the script will be the rotated rectangle called 'Rect'. This is what the be drawn as the part.
Script syntax
The description of a parametric part consists of the entire contents of a text file, except comments, tabs, and other control characters, which are ignored. Comments are specified either using "//" characters that mean that all subsequent characters up to the end of the line are comments, or using the pair "/" and "/" that denote beginning and end of thecomment, respectively.
A text description is a set of two types of operators:
<Identifier> and <Expression>;
Identifiers
The <Identifier> defines the symbolic name of an object. It is a set of Roman letters and Arabic numerals, which must start with a letter.
For example valid names would be:
PART2a MyPart A134
Object identifiers may not be the same as names of functions or such names as PI, or LINEAR. These are reserved words that are used to designate the constants of the scripting language. The list of all reserved names is provided in the reserved word list which appears at the end of this chapter.
Expressions
Expressions define the associated identifier. Expression syntax matches the expression syntax in the majority of programming languages. They may define numeric value, arithmetic operations, the dependence of the defined object on other objects and function calls.
The structure of a function call is:
<Function name> (<list of parameters>),
Examples of correct expression syntax:
(D --1/4) * k; Polyline(Point(0, 0.25 - 1/8), Point(0, D), Arc1(L-C, - m, m), Point(0,0)); A = B + 0.5; B = 7;
Arithmetic Operations
Arithmetic operations may use the standard arithmetical operators '+' (addition), '--'(subtraction), '*' (multiplication), '/' (Division) and parenthesis '('and ')', to determine the sequence of performing arithmetic operations. Object identifiers and numbers serve as operands.
Script Semantics
A script contains full description of a parametric part. The collection of script operators determines which actions need to be performed to create the resultant object(s). Correct understanding of a script, requires having a clear understanding of how its operators are interpreted. Identifiers that are used in a <Expression> must be defined. In other words it must have been used as:
<Identifier> = <Expression>;
The list of resultant objects is defined in the Output(..) operator. The Output(..) operator contains a list of which objects are to be displayed in the resulting part. This operator must be present in the script. Each object in the list of arguments for Output(..) must be defined. In other words it must have been used as:
<Identifier> = <Expression>;
This operator must be present in the script. At least one object must be listed in the Output operator, but you need not output every object used in the script. The Output operator determines the method that will be used to create an object with this name.
A correct script describing a parametric part should conform to the following rules:

...

  • Div
    Mod
    /
    -
    sin
    cos
    tan
    atan
    min
    max
    • =
      ==
      !=
      <
      >
      <=
      >=
      &
      Solid
      Extrude


      UNIQUE

      GraphicId

      VertexId

       

      Vertex

      Face

      Edge

      Source

      Bound

      Intersect

      OperationList

      BlendArg

      BlendParam

      BlendType

      BlendRadiusMode

      BlendSetback

      BlendRadiusBlendSmooth

      BlendRadiusParam

      BlendOffsetParam

      BlendFaceEntity

      BlendFaceEdge

      BlendFaceVertex

      BlendEdgeEdge

      BlendEdgeVertex

      BlendEdgeVertexMain

      BlendEdgeVertexAux

      ShellArg

      ShellThickness

      ShellFace

      ShellEdge

      FaceEditArg

      Transform

      ScaleX

      ScaleY

      ScaleZ

      ShearXY

      ShearXZ

      ShearYZ

      RotateX

      RotateY

      RotateZ

      TranslateX

      TranslateY

      TranslateZ

      Path

      Profile

      LateralFace

      LateralEdge

      CapFace

      CapEdge

      JointEdge

      Profiles

      HighLight

      FaceMaterialArg

      FaceMaterial

      FaceOffsetArg

      FaceHoleArg

      FaceHole

      BendId

      BendRadius

      BendAngle

      BendNeutral

      BendFlag

      BendPosition

      BendFlangeHeight

      BendAxialDistance

      BendAzimuthAngle

      BendEdgeStartPosition

      BendEdgeEndPosition

      Face2FaceLoftArg

      Face2FaceLoft

       

 


AssemblyAxis

Input

Output

Include

Units

StaticSymbol

FolderList

Macro

Parameters

Parameter

ParameterPoint

PointX

PointY

PointZ

Set

Interval

LessThan

GreaterThan

LessOrEquail

GreaterOrEqual

Circle

Rectangle

Polyline

Point

Arc0

Arc1

Fillet

IF

Move

Thickness

Sweep

Cone

BooleanUnion

BooleanSubtract

BooleanIntersect

G3Fillet

G3Chamfer

G3Shell

G3Offset

G3Slice

G3Bend

ExtentsX1

ExtentsX2

ExtentsY1

ExtentsY2

ExtentsZ1

ExtentsZ2

Text

TextFont

TextStyle

Group

SetProperties

PatternCopy

 

SDK
Available in TurboCAD Pro and Platinum only
The TurboCAD Software Development Kit enables you to program your own routines within TurboCAD. If you install TurboCAD using the Full installation, an SDK folder is created. This folder contains SDK samples and documentation (online help). Several SDK tools are provided in TurboCAD, located in the AddOns menu. These are located in the sections to which they are relevant. Each tool can be found in the index.
For more on the SDK see the TurboCAD Wiki
Using the Ruby Console
Available in TurboCAD Pro and Platinum only
When you first start TurboCAD, the Ruby Console opens as well. 

You can use the Ruby console to run functions, load ruby scripts, or even define new functions.
The top portion of the Ruby console is the Output Panel. This is where Ruby scripts will put text output, and where the Ruby engine will notify you of any errors that it has encountered, or provide other notifications. It is possible to copy text from the Output Panel to the clipboard for reuse in the Input Panel or elsewhere.
The bottom panel of the Ruby console is the Input Panel. Here you can type in any functions that you want to call, or define new values or even functions.
The Load… button allows you to open a ruby script using a standard "Open" dialog box.
The Save… button allows you to save the contents of the input panel as a ruby script using a standard "Save As" dialog box.
The Evaluate button tells Ruby to evaluate the text that you have typed into the Input Panel.
The Close button closes the Ruby Console. After you close the Ruby console you can re-open it at any time from the Scripts/Toggle Ruby Console menu command.
The Multiline checkbox allows you to turn Multiline input off or on.

...