Module: SkippyLib::Image
- Defined in:
- modules/image.rb
Overview
Class Method Summary collapse
- .clone_material(image, name: nil, force: false) ⇒ Sketchup::Material
- .definition(image) ⇒ Sketchup::ComponentDefinition
Class Method Details
.clone_material(image, name: nil, force: false) ⇒ Sketchup::Material
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'modules/image.rb', line 13 def self.clone_material(image, name: nil, force: false) definition = self.definition(image) material_name = name || "Copy of #{definition.name}" model = image.model # Reuse existing materials if it exists. Only checking for existing names. if force material = model.materials[material_name] return material if material end # Note that materials.add create unique names on demand. material = model.materials.add(material_name) # rubocop:disable SketchupSuggestions/Compatibility material.texture = image.image_rep # rubocop:enable SketchupSuggestions/Compatibility material end |
.definition(image) ⇒ Sketchup::ComponentDefinition
33 34 35 36 37 |
# File 'modules/image.rb', line 33 def self.definition(image) image.model.definitions.find { |definition| definition.image? && definition.instances.include?(image) } end |