Executing Script on Scripts Window


On Scripts Window, you can execute an input process line by line when inputting a C# script and pressing Enter key on the keyboard.
You can check script operation or use RootPro CAD APIs on a trial basis more easily than creating add-ins in Visual Studio or creating scripts with a text editor such as Notepad.

Displaying Scripts Window

  1. Click [Scripts Window] on [View] menu.
    Scripts Window will be displayed.

Imputing scripts on Scripts Window and executing them

  1. Place the cursor on the right side of ">" input prompt on Scripts Window.
    Now you can input scripts.
  2. Input a line of codes like normal scripts, and press Enter key on the keyboard.
    The input line contents will be executed immediately.
    When there is any mistake in input codes, an error message will be displayed in red texts. Check the contents and input correct codes.
  3. Continue inputting codes to be processed

Script Samples

Sample codes of scripts to add a circle with the center point at (100, 100) and radius at 100 on the current part drawing on the active drawing are shown below.
Copy the following codes and paste them on Scripts Window. For pasting, press Ctrl + P key on the keyboard, or right-click the mouse and click [Paste] on the short-cut menu.

You can also execute the scripts line by line by inputting each line of scripts and press Enter key on the keyboard.

var doc = Application.ActiveDocument; 
var drawing = doc.CurrentDrawing; 
var point = new Point2d(100, 100); 

doc.UndoManager.BeginUndoUnit(); 
drawing.Shapes.AddCircle(point, 100); 
doc.UndoManager.EndUndoUnit();

Checking variable details on Scripts Window

You can easily check variables for strings or numeric values defined in scripts, or property details that can retrieve strings or numeric values in RootPro CAD.

  1. Place the cursor on the right side of ">" input prompt on Scripts Window.
    Now you can input scripts.
  2. To check details of variables for strings or numeric values defined in scripts, input a variable name and press Enter key on the keyboard.
    For example, when the following variables of string type or double type are defined,
    >string text = "RootPro"; 
    >double length = "100.5";
    
    Input a variable name and press Enter key on the keyboard to display variable details in the following line. Do not input ";" after the variable name.
    * ">" indicates an input prompt, while ↵ shows Enter key.
    >text↵ 
    RootPro 
    >length↵ 
    100.5
    
  3. To check the property details that can retrieve strings or numeric values in RootPro CAD, input the property name and press Enter key on the keyboard.
    For example, to check the current layer name, input as follows. Do not input ";" after the variable name.
    * ">" indicates an input prompt, while ↵ shows Enter key.
    >Application.ActiveDocument.LayerTable.CurrentLayer.Name↵ 
    New Layer 1
    

Clearing Scripts Window

Delete all data input on Scripts Window.
However, the script execution status and variable details defined in the script will be retained.

  1. Right-click on Scripts Window.
    A short-cut menu will be displayed.
  2. Click [Clear Screen].
    Data input on Scripts Window will be deleted, and only an input prompt ">" will be displayed.

Resetting Scripts Window

Reset Script Window to a default status.
The screen will be cleared, and the script execution status and variable details defined in the script will be discarded.

  1. Right-click on Scripts Window.
    A short-cut menu will be displayed.
  2. Click [Reset].
    Data input on Scripts Window will be deleted, and only an input prompt ">" will be displayed.

Selecting and copying input line

Place the cursor on the line to be copied, and press Ctrl + A key on the keyboard to select the entire line.
Press Ctrl + C key on the keyboard in this state, or right-click the mouse and click [Copy] on the short-cut menu to copy the codes of one line to the Clipboard.

Press Ctrl + A key on the keyboard again while one line is selected to select all texts on Script Window.
Execute copying in this state will copy all texts on Script Window to the Clipboard. In such a case, all including the input prompt ">" and error message will be copied.

Supplemental
Script functions are only used in RootPro CAD Professional. RootPro CAD Free cannot use these functions.

Related topics