SketchUp  Ruby API Reference 

Class Index

Method Index

Developers Guide

Examples

Text class

The Text class contains method to manipulate a Text entity object.

Parent:Drawingelement

Methods: arrow_type, arrow_type=, display_leader=, display_leader?, has_leader?, leader_type, leader_type= , line_weight, line_weight=, point, point=, set_text, text, text=, vector, vector=

Example Code: texttests.rb

Instance Methods


arrow_type

The arrow_type method retrieves the current arrow type used for the leader text.

Syntax

arrow = text.arrow_type

Return Value

arrow – a numerical representation for the type of arrow.

Comments

Valid arrow types are 0 for none, 2 for dot, 3 for closed arrow, 4 for open arrow.

Example

type = text.arrow_type=0

 

 


arrow_type=

The arrow_type= method sets the arrow type used for leader text.

Syntax

arrow = text.arrow_type=type

Arguments

type – a numerical representation of the type of arrow to be set

Return Value

arrow – a numerical representation for the type of arrow.

Comments

Valid arrow types are 0 for none, 2 for dot, 3 for closed arrow, 4 for open arrow.

 

 


display_leader= 

The display_leader= method accepts true or false for whether to display the leader.

Syntax

status  = text.display_leader=status

Arguments

status – true if you want to display the leader text, false if you do not want to display the leader text.

Return Value

status – the status that you set.

Comments

Leader text that is not displayed is set to Hidden type.

Example

leader = text.display_leader=true

 

 


display_leader? 

The display_leader? method returns the status of the leader.

Syntax

status = text.display_leader?

Return Value

status – true if the leader is being displayed, false if it is not displayed.

Example 

status = text.display_leader?

 

 


has_leader? 

The has_leader method is used to determine if the Text object has a leader.

Syntax

status = text.has_leader?

Return Value

status - true if the Text object has a leader. False if the Text object does not have a leader.

Example 

coordinates = [10, 10, 10]
model = Sketchup.active_model        
entities = model.entities
point = Geom::Point3d.new coordinates
text = entities.add_text "This is a Test", point
status = text.has_leader?
if (status)
UI.messagebox status
else
UI.messagebox status
end

 

 


leader_type 

The leader_type method retrieves the currently set leader type.

Syntax

leader = text.leader_type

Arguments

leader – a numerical value representing the currently set leader type.

Return Value

leader – a numerical value representing the currently set leader type.

Example

leader = text.leader_type

 

 


leader_type= 

The leader_type = method sets the leader type.

Syntax

leader = text.leader.type=type

Arguments

type – a numerical value representing the leader type to be set.

Return Value

leader – a numerical value representing the leader type you just set.

Comments

Valid leader types are 0 for none, 1 for View based, and 2 for Pushpin

Example

leader = text.leader_type=1

 

 


line_weight 

The line_weight method returns a line weight in number of pixels.

Syntax

lineweight = text.line_weight

Return Value

lineweight – the line weight in pixels

Comments

Defalt line weight is 1.

Example

weight = text.line_weight

 

 


line_weight= 

The line_weight= method sets the line weight in pixels.

Syntax

lineweight = text.line_weight=weight

Arguments

weight – the line weight to be set (in pixels).

Return Value

The line weight that has been set.

Comments

Default line weight is 1.

Example

newweight = text.line_weight=4

 

 


point

The point method is used to get the point associated with the text.

Syntax

point3d = text.point

Return Value

point - a Point3d object.

Example

 

 


point=

The point= method is used to set the point associated with the text.

Syntax

status = text.point= point3d

Arguments

point3d - a Point3d object.

Return Value

status - true if successful, false if unsuccessful.

Example

 

 


set_text 

The set_text method is used to set the text within a Text object without recording an Undo operation.

Syntax

text = text.text “textstring”

Arguments

“textstring” – the string to be set within the Text object

Return Value

text – the Text object

Example

text = text.set_text "This is another text"

 

 


text 

The text method is used to retrieve the string version of a Text object

Syntax

textstring = text.text

Return Value

textstring – the string representation of the Text object

Example

textstring = text.text

 

 


text=

The text= method is used to set the string version of a Text object

Syntax

textstring = text.text= "text"

Return Value

textstring - the newly set text

Example 

textstring = text.text="This is another text"

 

 


vector

The vector method is used to get the vector associated with the text.

Syntax

vector = text.vector

 

Return Value

vector - a Vector3d object.

Example

 

 


vector=

The vector= method is used to set the vector associated with the text.

Syntax

status = text.vector= vector3d

Arguments

vector3d - a Vector3d object.

Return Value

status - true if successful, false if unsuccessful.

Example