Class: Sketchup::Material
Overview
The Material class represents a Texture or Color that can be applied to Drawingelements. It is most often applied to Faces.
You can pass any object that can be used as a material to a method that requires a material. Objects include actual Material, Color, and classes that can be converted to a color.
Workflow Constant Summary # collapse
- Sketchup::Material::WORKFLOW_CLASSIC
- Sketchup::Material::WORKFLOW_PBR_METALLIC_ROUGHNESS
Normal Style Summary # collapse
- Sketchup::Material::NORMAL_STYLE_OPENGL
- Sketchup::Material::NORMAL_STYLE_DIRECTX
Material Type Constant Summary # collapse
- Sketchup::Material::MATERIAL_SOLID
- Sketchup::Material::MATERIAL_TEXTURED
- Sketchup::Material::MATERIAL_COLORIZED_TEXTURED
Colorize Type Constant Summary # collapse
- Sketchup::Material::COLORIZE_SHIFT
- Sketchup::Material::COLORIZE_TINT
Owner Type Constant Summary # collapse
- Sketchup::Material::OWNER_MANAGER
- Sketchup::Material::OWNER_IMAGE
- Sketchup::Material::OWNER_LAYER
PBR Metallic Roughness Workflow # collapse
- #ao_enabled? ⇒ Boolean
-
#ao_strength ⇒ Float
A value between
0.0
and1.0
. - #ao_strength=(strenght) ⇒ Object
- #ao_texture ⇒ Sketchup::Texture
- #ao_texture=(texture) ⇒ Object
-
#metallic_factor ⇒ Float
A value between
0.0
and1.0
. - #metallic_factor=(factor) ⇒ Object
- #metallic_texture ⇒ Sketchup::Texture
- #metallic_texture=(texture) ⇒ Object
- #metalness_enabled=(enabled) ⇒ Object
- #metalness_enabled? ⇒ Boolean
- #normal_enabled? ⇒ Boolean
-
#normal_scale ⇒ Float
A value larger than or equal to
0.0
. - #normal_scale=(scale) ⇒ Object
- #normal_style ⇒ Integer
- #normal_style=(style) ⇒ Object
- #normal_texture ⇒ Sketchup::Texture
- #normal_texture=(texture) ⇒ Object
- #roughness_enabled=(enabled) ⇒ Object
- #roughness_enabled? ⇒ Boolean
-
#roughness_factor ⇒ Float
A value between
0.0
and1.0
. - #roughness_factor=(factor) ⇒ Object
- #roughness_texture ⇒ Sketchup::Texture
- #roughness_texture=(texture) ⇒ Object
- #workflow ⇒ Integer
Instance Method Summary # collapse
-
#<=>(material) ⇒ Integer
The #<=> method is used to compare two materials based on ##display_name.
-
#==(material) ⇒ Boolean
The #== method is used to test if two materials are the same.
-
#alpha ⇒ Float
The #alpha method is used to get the opacity of the material.
-
#alpha=(alpha) ⇒ Float
The #alpha= method is used to set the opacity of the material.
-
#color ⇒ Sketchup::Color
The #color method is used to retrieve the color of the material.
-
#color=(color) ⇒ Object
The #color= method is used to set the color of the material.
-
#colorize_deltas ⇒ Array(Float, Float, Float)
The #colorize_deltas method retrieves the HLS delta for colorized materials.
-
#colorize_type ⇒ Integer
The #colorize_type method retrieves the type of colorization of the material.
-
#colorize_type=(type) ⇒ Object
The #colorize_type= method set the type of colorization of the material.
-
#display_name ⇒ String
The #display_name method retrieves the name that is displayed within SketchUp for the material.
-
#materialType ⇒ Integer
The #materialType method retrieves the type of the material.
-
#name ⇒ String
The #name method retrieves the name of the material.
-
#name=(str) ⇒ String
The #name= method sets the name of the material.
-
#owner_type ⇒ Integer
The #owner_type method is used to determine what owns the material.
-
#save_as(filename) ⇒ Boolean
The #save_as method is used to write a material to a SKM file.
-
#texture ⇒ Sketchup::Texture?
The #texture method retrieves the texture of the material.
-
#texture=(arg) ⇒ Object
The #texture= method sets the texture for the material.
-
#use_alpha? ⇒ Boolean
The #use_alpha? method tells if the material uses transparency.
-
#write_thumbnail(path, max_size) ⇒ Boolean?
The #write_thumbnail method writes a bitmap thumbnail to the given file name.
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
↑ #<=>(material) ⇒ Integer
The #<=> method is used to compare two materials based on ##display_name.
↑ #alpha ⇒ Float
The #alpha method is used to get the opacity of the material.
The value will be between 0.0
and 1.0
. A value of 0.0
means that the material is completely transparent. A value of 1.0
means that the material is completely opaque.
↑ #alpha=(alpha) ⇒ Float
The #alpha= method is used to set the opacity of the material.
The value must be between 0.0
and 1.0
. A value of 0.0
means that the material is completely transparent. A value of 1.0
means that the material is completely opaque.
↑ #ao_enabled? ⇒ Boolean PBR Metallic Roughness Workflow
There is no setter for this property. Instead it's dictated whether a #ao_texture is set.
↑ #ao_strength ⇒ Float PBR Metallic Roughness Workflow
Returns A value between 0.0
and 1.0
.
↑ #ao_strength=(strenght) ⇒ Object PBR Metallic Roughness Workflow
↑ #ao_texture ⇒ Sketchup::Texture PBR Metallic Roughness Workflow
↑ #ao_texture=(image_path) ⇒ Object #ao_texture=(image_rep) ⇒ Object #ao_texture=(texture) ⇒ Object PBR Metallic Roughness Workflow
↑ #color ⇒ Sketchup::Color
↑ #color=(color) ⇒ Object
The #color= method is used to set the color of the material.
If the material has a Texture, then this turns it into a colorized texture.
To reset the color of a material with a colorized texture, set the color to nil
. If the texture is not colorized it'll be reset to some undefined default color.
↑ #colorize_deltas ⇒ Array(Float, Float, Float)
The #colorize_deltas method retrieves the HLS delta for colorized materials.
↑ #colorize_type ⇒ Integer
This value is only relevant when the #materialType is set to MATERIAL_COLORIZED_TEXTURED.
The #colorize_type method retrieves the type of colorization of the material.
↑ #colorize_type=(type) ⇒ Object
This value is only relevant when the #materialType is set to MATERIAL_COLORIZED_TEXTURED.
The #colorize_type= method set the type of colorization of the material.
↑ #display_name ⇒ String
The #display_name method retrieves the name that is displayed within SketchUp for the material.
This should be used when presenting the name in the UI, but the returned name cannot be used as a key in Sketchup::Model#materials.
↑ #materialType ⇒ Integer
The #materialType method retrieves the type of the material.
-
0
= solid (MATERIAL_SOLID) -
1
= textured (MATERIAL_TEXTURED) -
2
= colorized textured (MATERIAL_COLORIZED_TEXTURED)
The constants were added in SketchUp 2015.
↑ #metallic_factor ⇒ Float PBR Metallic Roughness Workflow
Returns A value between 0.0
and 1.0
.
↑ #metallic_factor=(factor) ⇒ Object PBR Metallic Roughness Workflow
↑ #metallic_texture ⇒ Sketchup::Texture PBR Metallic Roughness Workflow
↑ #metallic_texture=(image_path) ⇒ Object #metallic_texture=(image_rep) ⇒ Object #metallic_texture=(texture) ⇒ Object PBR Metallic Roughness Workflow
↑ #metalness_enabled=(enabled) ⇒ Object PBR Metallic Roughness Workflow
↑ #metalness_enabled? ⇒ Boolean PBR Metallic Roughness Workflow
↑ #name ⇒ String
The #name method retrieves the name of the material. This is the unique internal name of the object which should be used for retrieving the material from the model's material list.
Use #display_name to display the name in the UI.
↑ #name=(str) ⇒ String
Since SketchUp 2018 this method will raise an ArgumentError
if the name is not unique.
The #name= method sets the name of the material.
↑ #normal_enabled? ⇒ Boolean PBR Metallic Roughness Workflow
There is no setter for this property. Instead it's dictated whether a #normal_texture is set.
↑ #normal_scale ⇒ Float PBR Metallic Roughness Workflow
Returns A value larger than or equal to 0.0
.
↑ #normal_scale=(scale) ⇒ Object PBR Metallic Roughness Workflow
↑ #normal_style ⇒ Integer PBR Metallic Roughness Workflow
↑ #normal_style=(style) ⇒ Object PBR Metallic Roughness Workflow
↑ #normal_texture ⇒ Sketchup::Texture PBR Metallic Roughness Workflow
↑ #normal_texture=(image_path) ⇒ Object #normal_texture=(image_rep) ⇒ Object #normal_texture=(texture) ⇒ Object PBR Metallic Roughness Workflow
↑ #owner_type ⇒ Integer
The #owner_type method is used to determine what owns the material.
↑ #roughness_enabled=(enabled) ⇒ Object PBR Metallic Roughness Workflow
↑ #roughness_enabled? ⇒ Boolean PBR Metallic Roughness Workflow
↑ #roughness_factor ⇒ Float PBR Metallic Roughness Workflow
Returns A value between 0.0
and 1.0
.
↑ #roughness_factor=(factor) ⇒ Object PBR Metallic Roughness Workflow
↑ #roughness_texture ⇒ Sketchup::Texture PBR Metallic Roughness Workflow
↑ #roughness_texture=(image_path) ⇒ Object #roughness_texture=(image_rep) ⇒ Object #roughness_texture=(texture) ⇒ Object PBR Metallic Roughness Workflow
↑ #save_as(filename) ⇒ Boolean
You must remember to append “.skm” to the filename as this will not be done automatically.
The #save_as method is used to write a material to a SKM file.
↑ #texture ⇒ Sketchup::Texture?
The #texture method retrieves the texture of the material.
↑ #texture=(filename) ⇒ Object #texture=(properties) ⇒ Object #texture=(properties) ⇒ Object #texture=(image_rep) ⇒ Object
↑ #use_alpha? ⇒ Boolean
The #use_alpha? method tells if the material uses transparency. It uses some tolerance checking to account for floating point precision noise.
↑ #workflow ⇒ Integer PBR Metallic Roughness Workflow
When the workflow returns WORKFLOW_PBR_METALLIC_ROUGHNESS
the properties listed under PBR Metallic Roughness Workflow are relevant.
↑ #write_thumbnail(path, max_size) ⇒ Boolean?
The #write_thumbnail method writes a bitmap thumbnail to the given file name.