Class: Sketchup::HatchPatterns

Inherits:
Entity
  • Object
show all
Includes:
Enumerable

Overview

An HatchPatterns object is a collection of HatchPattern objects. It is used to manage the hatch patterns in a model.

An HatchPattern object represents an hatch pattern in the model.

Version:

  • SketchUp 2027.0

Instance Method Summary # collapse

Methods inherited from Entity

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

Instance Method Details

↑ #[](index) ⇒ Sketchup::HatchPattern? #[](name) ⇒ Sketchup::HatchPattern?

The #[] method is used to retrieve an Sketchup::HatchPattern by index or name.

Overloads:

Version:

  • SketchUp 2027.0

↑ #add(name, path) ⇒ Sketchup::HatchPattern

The #add method adds an Sketchup::HatchPattern to the Sketchup::HatchPatterns, loading it from a file. The name must be non-empty and unique within the model.

Examples:

hatch_patterns = Sketchup.active_model.hatch_patterns
path = 'path/to/pattern.skh'
hatch_pattern = hatch_patterns.add('Pattern', path)

Parameters:

  • name (String)
  • path (String) —

    the file to load the pattern from

Returns:

Raises:

  • (ArgumentError) —

    if the name is empty, already used by another hatch pattern, or the pattern could not be loaded from the file.

Version:

  • SketchUp 2027.0

↑ #each {|hatch_pattern| ... } ⇒ Sketchup::HatchPatterns

The #each method is used to iterate over all the patterns in the Sketchup::HatchPatterns.

Examples:

hatch_patterns = Sketchup.active_model.hatch_patterns
hatch_patterns.each { |hatch_pattern| puts hatch_pattern.name }

Yields:

  • (hatch_pattern)

Yield Parameters:

Returns:

Version:

  • SketchUp 2027.0

↑ #purge_unused ⇒ Sketchup::HatchPatterns

The #purge_unused method is used to remove unused hatch patterns.

Examples:

hatch_patterns = Sketchup.active_model.hatch_patterns
hatch_patterns.purge_unused

Returns:

Version:

  • SketchUp 2027.0

↑ #remove(pattern) ⇒ Boolean

The #remove method removes an Sketchup::HatchPattern from the Sketchup::HatchPatterns.

Examples:

hatch_patterns = Sketchup.active_model.hatch_patterns
path = 'path/to/pattern.skh'
hatch_pattern = hatch_patterns.add('Pattern', path)
hatch_patterns.remove(hatch_pattern)

Parameters:

Returns:

  • (Boolean) —

    true if the pattern was removed, false if it was not found

Version:

  • SketchUp 2027.0

↑ #selected_hatch_pattern ⇒ Sketchup::HatchPattern?

The #selected_hatch_pattern method retrieves the currently selected Sketchup::HatchPattern, mirroring the selection in the desktop UI, or nil if none is selected.

Examples:

hatch_patterns = Sketchup.active_model.hatch_patterns
pattern = hatch_patterns.selected_hatch_pattern

Returns:

Version:

  • SketchUp 2027.0

↑ #selected_hatch_pattern=(pattern) ⇒ Object

The #selected_hatch_pattern= method sets the currently selected Sketchup::HatchPattern, mirroring the selection in the desktop UI. Pass nil to clear the selection.

Examples:

hatch_patterns = Sketchup.active_model.hatch_patterns
hatch_patterns.selected_hatch_pattern = hatch_patterns['Pattern']

Parameters:

Raises:

  • (ArgumentError) —

    if the pattern does not belong to this collection.

Version:

  • SketchUp 2027.0

↑ #size ⇒ Integer Also known as: length

The #size method retrieves the number of hatch patterns in the Sketchup::HatchPatterns.

Examples:

hatch_patterns = Sketchup.active_model.hatch_patterns
number = hatch_patterns.size

Returns:

  • (Integer) —

    the number of hatch patterns

Version:

  • SketchUp 2027.0