My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google SketchUp Ruby API

Styles

class

Parent: Object

Introduction

SketchUp 6.0+

The Styles class contains methods for manipulating a collection of styles in a model. Typically, you will access this via the active_model:

     styles = Sketchup.active_model.styles
     UI.messagebox "There are " + styles.count.to_s + " styles in your model."

Methods

Styles.[]SketchUp 6.0+

The [] method is used to retrieves a style by either name or index.

Arguments:

name_or_index
The string name or index for a specific style.

Returns:

style
a Style object if successful
 styles = Sketchup.active_model.styles
 style1 = styles[0]
 style2 = styles["name"]

Styles.active_styleSketchUp 6.0+

The active_style method is used to retrieve the active style.

Returns:

style
the active Style object.
 styles = Sketchup.active_model.styles
 style = styles.active_style
 UI.messagebox('The active style is: ' + active_style.name)

Styles.active_style_changedSketchUp 6.0+

The active_style_changed method tells you if the active style has been edited by the user since it was last saved.

Returns:

changed
true if the active style has been changed from when it was last saved.
 styles = Sketchup.active_model.styles
 user_made_change = styles.active_style_changed
 UI.messagebox ('The active style was edited: ' + user_made_change.to_s)

Styles.add_styleSketchUp 6.0+

The add_style method is used to create and load a style from the given file.

Arguments:

filename
The filename for the style.
select
true if you want to set the style to be the active style, false if not.

Returns:

status
true if successful, false if unsuccessful.
 styles = Sketchup.active_model.styles
 status = styles.add_style "c:\\MyStyle.style", true
 UI.messagebox ('A style was added: ' + status.to_s)

Styles.countSketchUp 6.0+

The count method is used to retrieve the number of styles in the collection.

Returns:

count
the number of styles found.
 styles = Sketchup.active_model.styles
 how_many = styles.count
 UI.messagebox ('The in model styles are ' + how_many.to_s)

Styles.eachSketchUp 6.0+

The each method is used to iterate through styles.

Arguments:

style
Variable that will hold each style as it is found.

Returns:

nil
styles = Sketchup.active_model.styles
styles.each {| style |
  UI.messagebox('style: ' + style.name)
}

Styles.parentSketchUp 6.0+

The parent method is used to determine the model for the styles.

Returns:

model
the model that contains the styles if successful
 styles = Sketchup.active_model.styles
 model = styles.parent
 UI.messagebox ('The current Model ID is: ' + model.to_s)

Styles.purge_unusedSketchUp 6.0+

The purge_unused method is used to remove unused styles from the model.

Returns:

status
true if successful, false if unsuccessful.
 styles = Sketchup.active_model.styles
 status = styles.purge_unused
 UI.messagebox ('Purging Unused styles status: ' + status.to_s)

Styles.selected_styleSketchUp 6.0+

The selected_style method is used to retrieve the currently selected style.

Returns:

style
the selected Style object.
 styles = Sketchup.active_model.styles
 style = styles.selected_style
 UI.messagebox ('The selected style is: ' + style.name)

Styles.selected_style=SketchUp 6.0+

The selected_style= method is used to set the currently selected style.

Arguments:

style
The style object to select.

Returns:

false
 styles = Sketchup.active_model.styles
 styles.selected_style = styles[styles.count -1]

Styles.sizeSketchUp 6.0+

The size method is used to retrieve the number of styles in the collection. This is an alias for the Styles.count method.

Returns:

size
the number of styles found.
 styles = Sketchup.active_model.styles
 how_many = styles.size
 UI.messagebox ('The in model styles are ' + how_many.to_s)

Styles.update_selected_styleSketchUp 6.0+

The update_selected_style method returns true if the selected style was changed (e.g. the user selected a different style).

Returns:

status
true if the style was switched
 styles = Sketchup.active_model.styles
 success = styles.update_selected_style
 UI.messagebox ('The selected style was switched: ' + success.to_s)