|
SketchUp Ruby API Reference |
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
The arrow_type method retrieves the current arrow type used for the leader text.
arrow = text.arrow_type
arrow – a numerical representation for the type of arrow.
Valid arrow types are 0 for none, 2 for dot, 3 for closed arrow, 4 for open arrow.
type = text.arrow_type=0
The arrow_type= method sets the arrow type used for leader text.
arrow = text.arrow_type=type
type – a numerical representation of the type of arrow to be set
arrow – a numerical representation for the type of arrow.
Valid arrow types are 0 for none, 2 for dot, 3 for closed arrow, 4 for open arrow.
The display_leader= method accepts true or false for whether to display the leader.
status = text.display_leader=status
status – true if you want to display the leader text, false if you do not want to display the leader text.
status – the status that you set.
Leader text that is not displayed is set to Hidden type.
leader = text.display_leader=true
The display_leader? method returns the status of the leader.
status = text.display_leader?
status – true if the leader is being displayed, false if it is not displayed.
status = text.display_leader?
The has_leader method is used to determine if the Text object has a leader.
status = text.has_leader?
status - true if the Text object has a leader. False if the Text object does not have a leader.
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
The leader_type method retrieves the currently set leader type.
leader = text.leader_type
leader – a numerical value representing the currently set leader type.
leader – a numerical value representing the currently set leader type.
leader = text.leader_type
The leader_type = method sets the leader type.
leader = text.leader.type=type
type – a numerical value representing the leader type to be set.
leader – a numerical value representing the leader type you just set.
Valid leader types are 0 for none, 1 for View based, and 2 for Pushpin
leader = text.leader_type=1
The line_weight method returns a line weight in number of pixels.
lineweight = text.line_weight
lineweight – the line weight in pixels
Defalt line weight is 1.
weight = text.line_weight
The line_weight= method sets the line weight in pixels.
lineweight = text.line_weight=weight
weight – the line weight to be set (in pixels).
The line weight that has been set.
Default line weight is 1.
newweight = text.line_weight=4
The point method is used to get the point associated with the text.
point3d = text.point
point - a Point3d object.
The point= method is used to set the point associated with the text.
status = text.point= point3d
point3d - a Point3d object.
status - true if successful, false if unsuccessful.
The set_text method is used to set the text within a Text object without recording an Undo operation.
text = text.text “textstring”
“textstring” – the string to be set within the Text object
text – the Text object
text = text.set_text "This is another text"
The text method is used to retrieve the string version of a Text object
textstring = text.text
textstring – the string representation of the Text object
textstring = text.text
The text= method is used to set the string version of a Text object
textstring = text.text= "text"
textstring - the newly set text
textstring = text.text="This is another text"
The vector method is used to get the vector associated with the text.
vector = text.vector
vector - a Vector3d object.
The vector= method is used to set the vector associated with the text.
status = text.vector= vector3d
vector3d - a Vector3d object.
status - true if successful, false if unsuccessful.
|
SketchUp Ruby API Reference: Text |
© Google Inc. 2007 sketchup.google.com |