Class: Sketchup::HatchPattern

Inherits:
Entity
  • Object
show all

Overview

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

↑ #clear_fill_pattern ⇒ Sketchup::HatchPattern

The #clear_fill_pattern method removes the .pat line-pattern definition from the Sketchup::HatchPattern.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
hatch_pattern.clear_fill_pattern

Returns:

Version:

  • SketchUp 2027.0

↑ #clear_fill_texture ⇒ Sketchup::HatchPattern

The #clear_fill_texture method removes the texture fill from the Sketchup::HatchPattern.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
hatch_pattern.clear_fill_texture

Returns:

Version:

  • SketchUp 2027.0

↑ #fill_color ⇒ Sketchup::Color

The #fill_color method retrieves the solid fill color of the Sketchup::HatchPattern.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
color = hatch_pattern.fill_color

Returns:

Version:

  • SketchUp 2027.0

↑ #fill_color=(color) ⇒ Object

The #fill_color= method sets the solid fill color of the Sketchup::HatchPattern.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
hatch_pattern.fill_color = Sketchup::Color.new(255, 0, 0)

Parameters:

Version:

  • SketchUp 2027.0

↑ #fill_pattern_file_name ⇒ String

The #fill_pattern_file_name method retrieves the file path the .pat line-pattern definition was loaded from.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
path = hatch_pattern.fill_pattern_file_name

Returns:

  • (String) —

    the .pat source file path

Version:

  • SketchUp 2027.0

↑ #fill_texture_file_name ⇒ String

The #fill_texture_file_name method retrieves the file path the fill texture image was loaded from.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
path = hatch_pattern.fill_texture_file_name

Returns:

  • (String) —

    the texture source file path

Version:

  • SketchUp 2027.0

↑ #fill_texture_image ⇒ Sketchup::ImageRep?

The #fill_texture_image method retrieves the fill texture image of the Sketchup::HatchPattern, or nil if the pattern has no texture fill.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
image = hatch_pattern.fill_texture_image

Returns:

Version:

  • SketchUp 2027.0

↑ #name ⇒ String

The #name method retrieves the name of the Sketchup::HatchPattern.

Examples:

model = Sketchup.active_model
hatch_patterns = model.hatch_patterns
path = 'path/to/pattern.skh'
hatch = hatch_patterns.add('Pattern', path)
puts hatch.name # Outputs "Pattern"

Returns:

  • (String) —

    the name of the hatch pattern

Version:

  • SketchUp 2027.0

↑ #name=(name) ⇒ Object

The #name= method sets the name for an Sketchup::HatchPattern. The name must be non-empty and unique within the model.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
hatch_pattern.name = 'New name'

Parameters:

Raises:

  • (ArgumentError) —

    if the name is empty or already used by another hatch pattern.

Version:

  • SketchUp 2027.0

↑ #rotation_angle ⇒ Float

The #rotation_angle method retrieves the rotation angle applied to the Sketchup::HatchPattern, in degrees.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
angle = hatch_pattern.rotation_angle

Returns:

  • (Float) —

    the rotation angle in degrees

Version:

  • SketchUp 2027.0

↑ #rotation_angle=(angle) ⇒ Object

The #rotation_angle= method sets the rotation angle applied to the Sketchup::HatchPattern, in degrees.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
hatch_pattern.rotation_angle = 45.0

Parameters:

  • angle (Float)

Version:

  • SketchUp 2027.0

↑ #save_fill_pattern_to_file(file_name) ⇒ Sketchup::HatchPattern

The #save_fill_pattern_to_file method writes the .pat line-pattern definition to a file. This writes only the pattern definition, not the whole hatch pattern; use #write for the latter.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
hatch_pattern.save_fill_pattern_to_file('C:/patterns/ansi31.pat')

Parameters:

  • file_name (String) —

    the path to write the .pat file to.

Returns:

Raises:

  • (ArgumentError) —

    if the pattern has no .pat definition or the file could not be written.

Version:

  • SketchUp 2027.0

↑ #set_fill_pattern_from_file(file_name) ⇒ Sketchup::HatchPattern

Note:

A .pat file may hold more than one pattern definition. Only the first definition in

The #set_fill_pattern_from_file method loads a .pat line-pattern definition from a file.

the file is loaded; any others are ignored.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
hatch_pattern.set_fill_pattern_from_file('C:/patterns/ansi31.pat')

Parameters:

  • file_name (String) —

    the path to the .pat file to load.

Returns:

Raises:

  • (ArgumentError) —

    if the .pat file could not be loaded.

Version:

  • SketchUp 2027.0

↑ #set_fill_texture_image_and_file_name(image, file_name) ⇒ Sketchup::HatchPattern

The #set_fill_texture_image_and_file_name method sets the fill texture image and the file path it came from together, as a unit.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
image_rep = Sketchup::ImageRep.new('C:/textures/brick.png')
hatch_pattern.set_fill_texture_image_and_file_name(image_rep, 'C:/textures/brick.png')

Parameters:

Returns:

Raises:

  • (ArgumentError) —

    if image is not a ImageRep or does not contain valid image data.

Version:

  • SketchUp 2027.0

↑ #set_uv_scale(u_scale, v_scale) ⇒ Sketchup::HatchPattern

The #set_uv_scale method sets the UV scale of the Sketchup::HatchPattern. Both values must be positive. The scale is a factor applied to the pattern’s repeat; it is not a percentage.

Examples:

model = Sketchup.active_model
hatch_pattern = model.hatch_patterns['Pattern']
hatch_pattern.set_uv_scale(12.0, 12.0)

Parameters:

  • u_scale (Float)
  • v_scale (Float)

Returns:

Raises:

  • (ArgumentError) —

    if either scale is not a positive value.

Version:

  • SketchUp 2027.0

↑ #thumbnail_image ⇒ Sketchup::ImageRep

The #thumbnail_image method retrieves the cached preview image of the Sketchup::HatchPattern.

Examples:

hatch_pattern = Sketchup.active_model.hatch_patterns['Pattern']
image = hatch_pattern.thumbnail_image

Returns:

Version:

  • SketchUp 2027.0

↑ #uv_scale ⇒ Array(Float, Float)

The #uv_scale method retrieves the UV scale of the Sketchup::HatchPattern as a u and v pair. The scale is a positive factor applied to the pattern’s repeat; it is not a percentage.

Examples:

model = Sketchup.active_model
hatch_pattern = model.hatch_patterns['Pattern']
u_scale, v_scale = hatch_pattern.uv_scale

Returns:

  • (Array(Float, Float)) —

    the u and v scale factors

Version:

  • SketchUp 2027.0

↑ #write(path) ⇒ Boolean

Writes the hatch pattern to file as a .skh file.

Examples:

hp = Sketchup.active_model.hatch_patterns['Pattern']
hp.write('path/to/pattern.skh')

Parameters:

Returns:

  • (Boolean) —

    true if the method succeeded

Version:

  • SketchUp 2027.0