123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::HatchPattern

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Entity
Instance Chain:
self, Entity
Inherits: Sketchup::Entity

Overview

An HatchPattern object represents an hatch pattern in the model.

Version:

  • SketchUp 2027.0

Instance Attribute Summary

Entity - Inherited

#deleted?

The deleted? method is used to determine if your entity is still valid (not deleted by another script, for example.).

#valid?

The #valid? method is used to determine if your entity is still valid (not deleted by another script, for example).

Instance Method Summary

Entity - Inherited

#add_observer

The add_observer method is used to add an observer to the current object.

#attribute_dictionaries

The attribute_dictionaries method is used to retrieve the AttributeDictionaries collection attached to the entity.

#attribute_dictionary

The attribute_dictionary method is used to retrieve an attribute dictionary with a given name that is attached to an Entity.

#delete_attribute

The #delete_attribute method is used to delete an attribute from an entity.

#entityID

The entityID method is used to retrieve a unique ID assigned to an entity.

#get_attribute

The #get_attribute method is used to retrieve the value of an attribute in the entity's attribute dictionary.

#inspect

The #inspect method is used to retrieve the string representation of the entity.

#model

The model method is used to retrieve the model for the entity.

#parent

The parent method is used to retrieve the parent of the entity.

#persistent_id

The #persistent_id method is used to retrieve a unique persistent id assigned to an entity.

#remove_observer

The remove_observer method is used to remove an observer from the current object.

#set_attribute

The set attribute is used to set the value of an attribute in an attribute dictionary with the given name.

#to_s

The #to_s method is used to retrieve the string representation of the entity.

#typename

The typename method retrieves the type of the entity, which will be a string such as "Face", "Edge", or "Group".

Instance Attribute Details

#fill_color ⇒ Sketchup::Color (rw)

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

Examples:

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

Returns:

Version:

  • SketchUp 2027.0

#fill_color=(color) (rw)

The #fill_color= method sets the solid fill color of the 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

#name ⇒ String (rw)

The #name method retrieves the name of the 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) (rw)

The #name= method sets the name for an 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 (rw)

The #rotation_angle method retrieves the rotation angle applied to the 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) (rw)

The #rotation_angle= method sets the rotation angle applied to the 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

Instance Method Details

#clear_fill_pattern ⇒ HatchPattern

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

Examples:

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

Version:

  • SketchUp 2027.0

#clear_fill_texture ⇒ HatchPattern

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

Examples:

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

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 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

#save_fill_pattern_to_file(file_name) ⇒ 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.

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) ⇒ 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.

Raises:

  • (ArgumentError) —

    if the .pat file could not be loaded.

Version:

  • SketchUp 2027.0

#set_fill_texture_image_and_file_name(image, file_name) ⇒ 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:

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) ⇒ HatchPattern

The #set_uv_scale method sets the UV scale of the 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)

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 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 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