Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Available in TurboCAD Pro and Platinum only

When you first start TurboCAD, the Ruby Console opens as well. 
Image Added
Image Removed  
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... 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 Enable Multiline checkbox allows you to turn Multiline input off or on.

  • When Enable Multiline is unchecked (the default), only a single line of input in the input panel is evaluated. This mode is convenient for running already-defined functions or defining and setting variable values on the fly. In this mode, pressing the Enter key is the same as pressing the Evaluate button.
  • When Enable Multiline is checked, you are allowed to enter as many different lines of text as you want. In this mode, the Enter key works to end the current line and move the cursor to a new line, instead of performing the Evaluate function. Multiline mode can be useful if you want to quickly define a simple function right in the Ruby console. After you are done entering lines, be sure to uncheck Enable Multiline before pressing Evaluate.

Loading a script with the

...

Load… button

To load a ruby script, click on the Load... Load… button in the Ruby Console. This opens a dialog box that lets you browse to a ruby script and load its functions and other definitions into memory.
Note, however, that loading a script in this way will not automatically execute any of the methods in the script - you'll have to do that from the Ruby console as well. For example, if you want to execute a function draw_stuff which is contained in the ruby script ConsoleLoadSample.rb you would do the following:

  • Click on the "Load...Load…" button.
  • Using the "Open" dialog, browse to the folder containing ConsoleLoadSample.rb.
  • Highlight ConsoleLoadSample.rb in the file list, and click "Open". The Output Panel adds a line "true" to indicate the script was opened successfully, but nothing else visibly happens.
  • Type "draw_stuff" in the Input Panel, and click Evaluate or press Enter. Now the function draw_stuff will perform whatever tasks it is supposed to.

Once the script has been loaded, it remains in memory for the duration of the TurboCAD session - you won't have to reload the script each time you want to run the draw_stuff function; simply enter "draw_stuff" in the input panel and press Enter to run the function again.

...

You can also load a script by using the load command in the Input Panel. In this case, you must specify the full path to the script, and use double backslashes as path separators. For example:
load("C: \\
MyRubyScripts
draw_plus.rb")
If the script is loaded successfully, the Output Panel will print a "true" response. If not, the Output Panel will print out one or more error messages. As when you use the Load... button, loading a script in this fashion does not automatically run any of the functions in the script.

...