Class: Sketchup::HatchPatternData

Inherits:
Object
  • Object
show all

Overview

A HatchPatternData object holds the appearance settings of a hatch pattern detached from any named HatchPattern in the model. It is used to read and write the default section fill style stored in RenderingOptions#hatch_pattern.

The object returned by RenderingOptions#hatch_pattern is frozen, since it is a snapshot detached from the model. Mutate a dup of it (or a new instance) and assign it back to apply a change.

Examples:

model = Sketchup.active_model
data = model.rendering_options.hatch_pattern.dup
data.rotation_angle = 45.0
model.rendering_options.hatch_pattern = data

Version:

  • SketchUp 2027.0

Instance Method Summary # collapse

Constructor Details

↑ #initialize ⇒ Sketchup::HatchPatternData

Examples:

data = Sketchup::HatchPatternData.new

Version:

  • SketchUp 2027.0

Instance Method Details

↑ #==(other) ⇒ Boolean

Two Sketchup::HatchPatternData objects are equal when all their settings match.

Examples:

data == other_data

Parameters:

  • other (Object)

Returns:

  • (Boolean)

Version:

  • SketchUp 2027.0

↑ #clear_fill_pattern ⇒ Sketchup::HatchPatternData

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
data.clear_fill_pattern

Returns:

Version:

  • SketchUp 2027.0

↑ #clear_fill_texture ⇒ Sketchup::HatchPatternData

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
data.clear_fill_texture

Returns:

Version:

  • SketchUp 2027.0

↑ #dup ⇒ Sketchup::HatchPatternData

The #dup method creates a copy of the Sketchup::HatchPatternData with all its properties.

Examples:

original = Sketchup.active_model.rendering_options.hatch_pattern
duplicate = original.dup
duplicate.rotation_angle = 90.0
original.rotation_angle # Unchanged.

Returns:

Version:

  • SketchUp 2027.0

↑ #fill_color ⇒ Sketchup::Color

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
color = data.fill_color

Returns:

Version:

  • SketchUp 2027.0

↑ #fill_color=(color) ⇒ Object

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
data.fill_color = Sketchup::Color.new(255, 0, 0)

Parameters:

Version:

  • SketchUp 2027.0

↑ #fill_pattern_file_name ⇒ String

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
path = data.fill_pattern_file_name

Returns:

Version:

  • SketchUp 2027.0

↑ #fill_texture_file_name ⇒ String

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
path = data.fill_texture_file_name

Returns:

Version:

  • SketchUp 2027.0

↑ #fill_texture_image ⇒ Sketchup::ImageRep?

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
image = data.fill_texture_image

Returns:

Version:

  • SketchUp 2027.0

↑ #rotation_angle ⇒ Float

The rotation angle is in degrees.

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
angle = data.rotation_angle

Returns:

  • (Float)

Version:

  • SketchUp 2027.0

↑ #rotation_angle=(angle) ⇒ Object

The rotation angle is in degrees.

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
data.rotation_angle = 45.0

Parameters:

  • angle (Float)

Version:

  • SketchUp 2027.0

↑ #save_fill_pattern_to_file(file_name) ⇒ Sketchup::HatchPatternData

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
data.save_fill_pattern_to_file('C:/patterns/ansi31.pat')

Parameters:

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

Note:

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

the file is loaded; any others are ignored.

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
data.set_fill_pattern_from_file('C:/patterns/ansi31.pat')

Parameters:

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

The image and the file path it came from are set together, as a unit.

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
image_rep = Sketchup::ImageRep.new('C:/textures/brick.png')
data.set_fill_texture_image_and_file_name(image_rep, 'C:/textures/brick.png')

Parameters:

Returns:

Raises:

  • (TypeError) —

    if image is not a ImageRep.

  • (ArgumentError) —

    if image does not contain valid image data.

Version:

  • SketchUp 2027.0

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

Both values must be positive.

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
data.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

↑ #uv_scale ⇒ Array(Float, Float)

The scale is a factor applied to the pattern’s repeat; it is not a percentage.

Examples:

data = Sketchup.active_model.rendering_options.hatch_pattern
u_scale, v_scale = data.uv_scale

Returns:

Version:

  • SketchUp 2027.0