Class: Sketchup::Styles

Inherits:
Entity
  • Object
show all
Includes:
Enumerable

Overview

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

Examples:

styles = Sketchup.active_model.styles
puts "There are #{styles.size} styles in your model."

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Methods inherited from Entity

#add_observer, #attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #persistent_id, #remove_observer, #set_attribute, #to_s, #typename, #valid?

Instance Method Details

#[](name) ⇒ Sketchup::Style? #[](index) ⇒ Sketchup::Style?

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

Examples:

styles = Sketchup.active_model.styles
style1 = styles[0]
style2 = styles["MyStyle"]

Overloads:

Version:

  • SketchUp 6.0

#active_styleSketchup::Style

The #active_style method is used to retrieve the active style.

While #selected_style is the style being selected in the Style Browser, the ##active_style is a different object also including any unsaved style changes. These changes are silently dropped once a new style is selected. To save these changes to the selected style, call ##update_selected_style.

Examples:

styles = Sketchup.active_model.styles
style = styles.active_style

Returns:

Version:

  • SketchUp 6.0

#active_style_changedBoolean

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

Examples:

styles = Sketchup.active_model.styles
style_changed = styles.active_style_changed

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0

#add_style(filename, select) ⇒ Boolean

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

Examples:

filename = File.expand_path('./MyStyle.style')
styles = Sketchup.active_model.styles
status = styles.add_style(filename, true)

Parameters:

  • filename (String)
  • select (Boolean)

    true if you want to set the style to be the active style.

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0

#countInteger

Note:

Since SketchUp 2014 the count method is inherited from Ruby's Enumable mix-in module. Prior to that the #count method is an alias for #length.

Examples:

styles = Sketchup.active_model.styles
number = styles.count

Returns:

  • (Integer)

Version:

  • SketchUp 6.0

#each {|style| ... } ⇒ nil

The #each method is used to iterate through styles.

Examples:

styles = Sketchup.active_model.styles
styles.each { |style|
  puts style.name
}

Yield Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#lengthInteger

The #length method is an alias of #size.

Examples:

styles = Sketchup.active_model.styles
number = styles.length

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 2014

#parentSketchup::Model

The #parent method is used to return the model for the styles.

Examples:

styles = Sketchup.active_model.styles
model = styles.parent

Returns:

Version:

  • SketchUp 6.0

#purge_unusedtrue

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

Examples:

styles = Sketchup.active_model.styles
styles.purge_unused

Returns:

  • (true)

Version:

  • SketchUp 6.0

#selected_styleSketchup::Style

The #selected_style method is used to retrieve the style currently selected in the Styles Browser.

Examples:

styles = Sketchup.active_model.styles
style = styles.selected_style

Returns:

Version:

  • SketchUp 6.0

#selected_style=(style) ⇒ false

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

Examples:

styles = Sketchup.active_model.styles
styles.selected_style = styles.last

Parameters:

Returns:

  • (false)

Version:

  • SketchUp 6.0

#sizeInteger

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

Examples:

styles = Sketchup.active_model.styles
number = styles.size

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0

#update_selected_styletrue

The #update_selected_style method commits the current style settings to the style selected in the Style Browser.

Examples:

styles = Sketchup.active_model.styles
styles.update_selected_style

Returns:

  • (true)

See Also:

Version:

  • SketchUp 6.0