# 3.3.2.16 Draw

The draw command supports two groups of options: Options to draw and set formatting for lines and Options to perform various operations on named objects:

## Draw Lines Syntax:

draw [-n LineName] [option(s)] -l [-h / -v] value

Create a line or alter a named line. To create an arbitrary line, value should specify the beginning and ending X and Y values, as follows: {X1, Y1, X2, Y2}.

If -h is specified, a horizontal line is created at the Y position of value.

If -v is specified, a vertical line is created at the X position specified by value.

 Note1: To create a movable line, use -lm instead of -l. If you named the line, then you can alternatively use the HMOVE (horizontal move allowed) and VMOVE (vertical move allowed) properties of a line object.
 Note2: By default, lines and arrows are attached to the Layer and Scales. By naming the line, you can access the ATTACH property to set as needed { PAGE = 1, LAYER FRAME = 0 or LAYER & SCALES = 2}. To disable this, set @AR = 0.

### Options:

Any of the following options can be used to set line characteristics. Options are cumulative.

#### no option; Create a line with default color, dash, and width settings

Syntax: draw no option

Create a line with default color, dash, and width settings. The line will not have an enumerated name. To alter a name, double-click on the line to open the Object Properties dialog box. Go to the Programming tab.

#### -c #; Set line color

Syntax: draw -c #

Set line color. # equals the numeric position in the color list starting with zero (black = 0, red = 1, green = 2, etc.).

#### -d #; Set dash pattern

Syntax: draw -d #

Set dash pattern. # equals the numeric position in the dash pattern list starting with zero (Solid = 0, dash = 1, dot = 2, etc.).

#### -w #; Set line width

Syntax: draw -w #

Set line width. # equals point size.

## Draw Rect Syntax:

You can create a new Rectangle object with the -b option:

draw -n ObjectName -b

The position of the rectangle can be specified by object.x/object.y, which is introduced in this page.

## Draw Bracket Syntax:

draw -n ObjectName -bracket  [option(s)] {basePos, x1, y1, x2, y2}

Use this syntax to draw a bracket object indicating statistical significance, on a graph. This feature works only for plots in the 2D Cartesian coordinate system.

Position the bracket using the {basePos, x1,y1,x2,y2...} position array. The first value specifies the position of the baseline (a y-coordinate for a horizontal bracket object; an x-coordinate for a vertical bracket object). The subsequent values are the coordinates of each prong's end position. Units are specified by an -a or -u switch (See below).

### Options:

#### -a attachmentIndex; Specifies the object attachment

This option switch uses an attachmentIndex to specify the object attachment, i.e. to Page, or Layer Frame, or Layer and Scale.

In which attachmentIndex = 0 means attach object to Layer Frame; = 1 means attach to Page; = 2 means attach to Layer and Scale. If this option is not used, the object will be attached to Layer and Scale.

To check the object attachment, right click on the object and select Programming Control to view.

#### -h / -v; Determine the orientation of the bracket object

The -h option switch means to create a horizontal bracket, while -v means to create a vertical one. If neither is specified, the horizontal orientation will be used.

#### -m var_name; Output object name

Output the generated object name to a pre-defined string variable var_name.

#### -t linked_text; Create a text object and connect to the bracket object

This option switch creates a text object which will be linked (connected) to the bracket object. It should be followed by a string to specify the content of the text object.

#### -u position_unit; Specify the actual units used for the position array

This option switch is used to specify the actual units used for the position array in curly braces. The position_unit = 0 means percentage of layer frame; = 1 means percentage of page setting; = 2 means scale unit.

If not specified, the unit setting will follow the unit defined by the -a switch.

## Draw Object Syntax:

draw -n ObjectName [option(s)]

Alter an existing named object as specified by the options. Options are cumulative. Only named objects can be altered by LabTalk script.

To create an object:

1. Select a tool from the Tools toolbar (such as the Arrow or Text tool).
2. Click in an open area within an Origin window and create the object.

A text label can also be created from script with the label command.

To name an object:

1. Hold down the ALT key and double-click on the object. This action opens the Object Properties dialog box.
2. Enter a name in the Object Name text box.
3. Click OK.

### Options:

#### -f save fileName; Save ObjectName to a fileName.OGO file

Syntax: draw -f save fileName

Save ObjectName to a fileName.OGO file. fileName can contain the DRIVE:PATH specification. If there is no path specified, then Origin tries to save to the EXE folder. When used on an object with script in the Label Control dialog box, this command copies the object's script and all settings along with the object.

#### -f read fileName; Create a named object

Create the named object from a stored OGO file. When no path is specified, Origin searches the User Files Folder first, then the Origin EXE folder. You cannot replace a named object with another object. You should delete the unwanted object (label -r ObjectName) and create a new object.

#### -fb save filename; Save ObjectName to a fileName

Syntax: draw -fb save fileName

Save ObjectName to a fileName.OGO file. ObjectName must be a bitmap object.

#### -fb read fileName; Create a bitmap object

Create a bitmap object named ObjectName or read a bitmap from a file into an existing object named ObjectName. The ObjectName object must be a bitmap object. fileName can contain the DRIVE:PATH specification.

Read a metafile from a file into the named object ObjectName. The ObjectName object must be a metafile object. fileName can contain the DRIVE:PATH specification.

#### -i inverse; Turn the ObjectName object inverse mode

Syntax: draw -i inverse

Turn the ObjectName object inverse mode On (1) and Off (0). This refers to the Button Edit Mode. When the ObjectName object inverse mode is On then it's edit state is the opposite of Button Edit Mode. Button Edit mode displays object names in the upper left and their scripts will not run. Use the -u option to refresh after using the -i option.

#### -nl; Put the last-created graph object name into string register

Syntax: draw -nl String Register

Put the last-created graph object name into a string register.

#### -nlc; Clear the last-created graph object name

Syntax: draw -nlc

Clear the last-created graph object name.

#### -r; Run the named object's script

Syntax: draw -r

Run the named object's script. The ObjectName.run() method can also be used to execute an object's script.

#### -s value; Show or hide the ObjectName object

Syntax: draw -s value

Show or hide the ObjectName object. value = 1 to show, 0 to hide. You can also use the SHOW property of an object : ObjectName.SHOW.

#### -u; Update objectName

Syntax: draw -u

Update objectName. The object is redrawn without redrawing the entire graph. The objectName.draw() method can also be used to update a named object.

#### -uf; The object is redrawn without redrawing the entire graph

Syntax: draw -uf

The object is redrawn without redrawing the entire graph. Only parts of the object that support this option are redrawn.

#### -v set; Set all numeric fields

Syntax: draw -v set

Set all numeric fields in the objectName's content to values in variables v1, v2, v3, etc. Numeric fields must be proceeded by an "=" sign. This command applies only to UIM objects or text objects. Refresh the object after using this command.

#### -v get; Assign the values

Syntax: draw -v get

Assign the values in all numeric fields in the objectName's content to variables v1, v2, v3, etc. The reverse of -v set. This command applies only to UIM objects or text objects.

#### -x value; Set objectName's X position

Syntax: draw -x value

Set objectName's X position to the specified value in the current X axis scale. You can also use the X property of an object : ObjectName.X.

#### -Y value; Set objectName's Y position

Syntax: draw -y value

Set objectName's Y position to the specified value in the current Y axis scale. You can also use the Y property of an object : ObjectName.Y.

#### -z get; Copy the message

Syntax: draw -z get

Copy the message of the objectName text label into the %Z string variable. The specified object must be a text label or the command returns an error. You can also use the TEXT$property of an object : ObjectName.TEXT$.

#### -z set; Copy the message

Syntax: draw -z set

Copy the message of the %Z string variable to the objectName text label's content.The specified object must be a text label or the command returns an error. The reverse of -z get. You can also use the TEXT$property of an object : ObjectName.TEXT$.

## Examples:

The following script creates a dashed vertical line that runs the height of the layer frame.

draw -d 2 -l -v (X1+(X2-X1)/2);

The next script creates a horizontal line at the center of the graph, with the name YLine.

draw -n YLine -L -h [(y1+y2)/2];

The next script moves YLine (previous example) to the top of the graph.

draw -n YLine -L -h y2;

The following script creates a green, 4-point-wide, dotted line that runs from coordinates 3, 5 to 8, 2.

draw -c 2 -w 4 -d 2 -l {3, 5, 8, 2};

The next script copies the metafile MYFILE.WMF into the named metafile object MyObject.

draw -n MyObject -fm read C:\MYDIR\MYFILE.WMF;

In the following script, assume myText is a named text label with the original content: mean = 8.2 and sd = 1.2. The script redraws the object to become: mean = 10.3 and sd = 2.5.

v1 = 10.3;
v2 = 2.5;
draw -n myText -v set -u;
doc -uw;  // refresh the window

which could also be written

myText.TEXT\$ = "mean = 10.3 and sd = 2.5";

The following script creates a bracket object with asterisk in an empty graph, the bracket object will be attached to page:

//Create empty graph
win -t plot;
//Draw bracket object named as bracket
draw -n bracket -bracket -a 1 -t * {0.3, 0.5, 0.5, 0.7, 0.7};

The following script draws a EMF image to the active graph as an object and put the object name to Z string register.

draw -nlc; // Clears last created graph object name.
draw -fm read C:\file.emf; // Reads meta file and draws on the active graph graph.
draw -nl Z; // Puts last created graph object name in Z string register.
;