Class: ModraUp::HatchPattern
- Inherits:
-
ModraUp::Entity
- Object
- ModraUp::Entity
- ModraUp::HatchPattern
Overview
A hatch pattern in a model (an item of ModraUp::Model#hatch_patterns): overlay .PAT line families or tiled images on the fill color, with scaling and rotation. Groups, components, materials, and section planes reference it via hatch_pattern=. Cannot be instantiated directly with new, instead use ModraUp::HatchPatterns#add.
The order in which hatch patterns are applied to a section area: first, the pattern of the containing group or component (including nested content), then the material's pattern, then the section plane's pattern, and finally, if none are specified, ModraUp::RenderingOptions#hatch_pattern.
Instance Method Summary # collapse
-
#clear_fill_pattern ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Clear the .PAT line pattern definition (the #fill_pattern_file_name will be empty), while preserving the fill color and texture.
-
#clear_fill_texture ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Clear the fill texture, retaining the fill color and .PAT line family.
-
#fill_color ⇒ ModraUp::Color
Retrieve the fill color (the background color beneath lines and patterns).
-
#fill_color=(color) ⇒ ModraUp::Color
Sets the fill color.
-
#fill_pattern_file_name ⇒ String
The path to the line pattern file (.PAT / .skh / .oskh); an empty string if no line pattern is defined.
-
#fill_texture_file_name ⇒ String
The path to the texture source file; an empty string if no texture is used.
-
#fill_texture_image ⇒ ModraUp::ImageRep, nil
Returns the image used for texture filling; returns nil if no texture is applied.
-
#rotation_angle ⇒ Float
Reads the rotation angle (degrees, counterclockwise).
-
#rotation_angle=(angle) ⇒ Float
Sets the rotation angle (degrees).
-
#save_fill_pattern_to_file(file_name) ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Write the .PAT hatch pattern as an AutoCAD .PAT text file (excluding fill color, scale, and texture; use ModraUp::HatchPattern#write for the entire pattern).
-
#set_fill_pattern_from_file(file_name) ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Read hatch patterns from a file. Only the first pattern in the file is used; also accepts line patterns from .skh / .oskh files.
-
#set_fill_texture_image_and_file_name(image, file_name) ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Set fill texture: The image and its source path are saved. The new texture initially tiles 12 inches wide, then scaled by #uv_scale.
-
#set_uv_scale(u_scale, v_scale) ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Sets the repeat scale in the U/V directions (pattern units × scale = model inches).
-
#uv_scale ⇒ Array(Float, Float)
Retrieve the U/V repetition scale.
-
#name ⇒ String
Read name (unique within the model).
-
#name=(name) ⇒ String
Rename. The name cannot be empty and must be unique and not conflict with other hatch patterns in the model.
-
#thumbnail_image ⇒ ModraUp::ImageRep, nil
Returns the thumbnail preview image (128×128) displayed in the thumbnail tray.
-
#write(path) ⇒ Boolean
Write the entire hatch pattern (name, source, fill color, line family or texture, scale, rotation) to a file.
Inherited from ModraUp::Entity
-
#typename ⇒ String
Type name (e.g., Face / Edge / Group).
-
#entityID ⇒ Integer
Entity ID within the current session: A small integer starting from 1 that increments and remains constant for the lifetime of the entity, unchanged by undo/redo operations. This ID is not preserved when saving the file; it will be renumbered upon reopening the model. For cross-session identification, use #persistent_id. Copied entities will receive new IDs.
-
#add_observer(observer) ⇒ Boolean
Register a ModraUp::EntityObserver. Adding the same object a second time returns false. Locking, property, and material changes will dispatch an onChangeEntity event.
-
#remove_observer(observer) ⇒ Boolean
Remove the entity observer.
-
#persistent_id ⇒ Integer
Number assigned with the model: A unique, incrementing small integer starting from 1 that persists across model saves and reloads, independent of #entityID. Copied entities receive new numbers, and deleted entities do not reuse their numbers. Edges, faces, vertices, curves, groups, component instances/definitions, dimensions, leader lines/points, section planes, materials, layers, layer folders, and drawing sheets have assigned numbers; all others (rings, EdgeUses, attribute dictionaries, line types, sets, etc.) return 0.
-
#parent ⇒ ModraUp::Model, ModraUp::ComponentDefinition
Returns the owner of this drawing context. At the root this is the model. Inside a definition it is the definition itself.
-
#model ⇒ ModraUp::Model
The model it belongs to.
-
#to_s ⇒ String
String form. Returns "#<Deleted Entity>” when the entity has been deleted.
-
#inspect ⇒ String
Same as #to_s.
-
#attribute_dictionaries ⇒ ModraUp::AttributeDictionaries, nil
Collection of attribute dictionaries. Returns nil (evaluates to false) if there are no dictionaries.
-
#attribute_dictionary(name) ⇒ ModraUp::AttributeDictionary, nil
Retrieve an attribute dictionary by name. If none exists, return nil; if create is true, create an empty dictionary. ModraUp::Loop / ModraUp::EdgeUse / ModraUp::Curve always return nil.
-
#valid? ⇒ Boolean
Returns true if the entity is valid, meaning it has not been deleted from the model. Revoked entities are false; even if new geometry is drawn occupying its original position, this object remains an invalid entity (still false). Repeating the action to restore it makes it valid again.
-
#deleted? ⇒ Boolean
Opposite of #valid?.
-
#set_attribute(dict_name, key, value) ⇒ Object
Write attribute values. Materials, groups, component instances, faces, and edges are supported. When dict_name and key are Symbols, they are converted to strings. The type of data written is the same type that will be read back.
-
#get_attribute(dict_name, key, default = nil) ⇒ Object
Read the attribute. If dict_name and key are Symbols, convert them to strings (similar to SketchUp). If the dictionary or key does not exist, return default. The return value type is the same as what is written by #set_attribute.
-
#delete_attribute(dict_name) ⇒ Boolean
Delete a key, or delete the entire dictionary when the key is omitted.
Instance Method Details
#clear_fill_pattern ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Clear the .PAT line pattern definition (the #fill_pattern_file_name will be empty), while preserving the fill color and texture.
#clear_fill_texture ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Clear the fill texture, retaining the fill color and .PAT line family.
#fill_color ⇒ ModraUp::Color
Retrieve the fill color (the background color beneath lines and patterns).
#fill_color=(color) ⇒ ModraUp::Color
Sets the fill color.
#fill_pattern_file_name ⇒ String
The path to the line pattern file (.PAT / .skh / .oskh); an empty string if no line pattern is defined.
#fill_texture_file_name ⇒ String
The path to the texture source file; an empty string if no texture is used.
#fill_texture_image ⇒ ModraUp::ImageRep, nil
Returns the image used for texture filling; returns nil if no texture is applied.
#rotation_angle ⇒ Float
Reads the rotation angle (degrees, counterclockwise).
#rotation_angle=(angle) ⇒ Float
Sets the rotation angle (degrees).
#save_fill_pattern_to_file(file_name) ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Write the .PAT hatch pattern as an AutoCAD .PAT text file (excluding fill color, scale, and texture; use ModraUp::HatchPattern#write for the entire pattern).
#set_fill_pattern_from_file(file_name) ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Read hatch patterns from a file. Only the first pattern in the file is used; also accepts line patterns from .skh / .oskh files.
#set_fill_texture_image_and_file_name(image, file_name) ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Set fill texture: The image and its source path are saved. The new texture initially tiles 12 inches wide, then scaled by #uv_scale.
#set_uv_scale(u_scale, v_scale) ⇒ ModraUp::HatchPattern, ModraUp::HatchPatternData
Sets the repeat scale in the U/V directions (pattern units × scale = model inches).
#uv_scale ⇒ Array(Float, Float)
Retrieve the U/V repetition scale.
#name ⇒ String
Read name (unique within the model).
#name=(name) ⇒ String
Rename. The name cannot be empty and must be unique and not conflict with other hatch patterns in the model.
#thumbnail_image ⇒ ModraUp::ImageRep, nil
Returns the thumbnail preview image (128×128) displayed in the thumbnail tray.
#write(path) ⇒ Boolean
Write the entire hatch pattern (name, source, fill color, line family or texture, scale, rotation) to a file.
ModraUp can read it back, but SketchUp cannot.