Script Editor

The Script Editor has the following functions.

  • Open Script - Loads a script from a file
  • Save Script - Saves the current script to a file
  • Save Script As - Saves the current script by specifying a destination
  • Insert Selection - Pastes the current selection as script in the script window. The selection can be identified by:
    • Index - The internal index of each selected entity
    • Ray - The internal ray fire point and direction
    • Smart Variable - Combines the other methods to make selections persist better when replaying scripts
      • Smart Variable selection is needed to make selections more stable for replaying changes. A Smart Variable selection stores more information than any of the other types and is much more robust in matching the selected entity during geometry changes.

      • The image below shows how each selection is scripted for the same selected face. Notice that the Smart Variable selection uses a variable called "Face1".

      • Smart Variables have a dropdown GUI, on mouse-over, for investigating references beyond the in-graphics highlighting.
  • Record - Code for scriptable actions performed in SpaceClaim is written in the script window. Choose the Normal or Verbose mode.
  • Insert Code Snippet - Presents the Snippet dropdown at the cursor in the script window
  • Find/Replace - Opens a Find and Replace dialog
  • Run Next Line - Executes the next line of the script

    The Step Over, Step In, and Step Out options in the drop-down for Run Next Line only apply to functions defined in the script, not native SpaceClaim function calls.

    • Step Over - The debugger executes the function call and then pauses after the function returns.
    • Step In - The debugger executes the function call statement and then pauses execution at the first line of the function called.
    • Step Out - Only applies if execution is first stopped inside a function (by a breakpoint inside function or when Step In is activated). The debugger executes the rest of the function without pausing, and then returns to the line after the function call and pauses.
    Note: Step Over and Step In will work even if breakpoints are not defined.
  • Run Script - Executes the entire script from the top. Select Debug or Run mode from the drop-down.
    • Debug - Debug mode enables you to use the Step Over, Step In, or Step Out features to debug your script as you work through it.
    • Run - Run mode ignores breakpoints and is quicker since it runs on the same thread.
    Note: Debug runs on a background thread so there is a performance cost. Using Run is faster, since it runs on a single thread, but breakpoints will not work when you run your code.
  • Breakpoints - You can left or middle click the grey column to the left of the line numbers to create a breakpoint, which is displayed by a big red circle.

    When you click the Run Next Line or Run Script button in Debug mode, script execution stops the first time it reaches the breakpoint line. Clicking either button again after this forces it to run the breakpoint line. The Run Script will continue to the next breakpoint line.

The editor supports the following shortcuts:

  • Ctrl+K = Comment
  • Ctrl+Shift+K = Uncomment
  • Ctrl+ Insert = Insert Code Snippet
  • Ctrl + F / Ctrl + H = Find/Replace
  • F10 = Run Next Line
  • F5 = Run Script
  • For Debug:
    • F10 = Step Over
    • F11 = Step In
    • Shift + F11 = Step Out

Script is written in the main Script window but can also be entered as single commands in the command line.

Note: The Script Editor scales units depending on the Length scale used. It uses meters (1 m) for Standard Length scale, millimeters (1 mm) for Small Length scale, and (1 km) kilometers for Large Length scale.

Results of running a script, including error and warnings, are written to the Output window.