123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::Environments

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

Overview

An Environments object is a collection of Environment objects. It is used to manage the environments in a model.

An Environment object represents an environment in the model. Environments are used to control the background and lighting of the model. Environments can be used as skyboxes, for reflections, and to link the sun to the environment.

Version:

  • SketchUp 2025.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

#currentSketchup::Environment? (rw)

The #current method is used to get the current environment in the Environments.

Examples:

environments = Sketchup.active_model.environments
current = environments.current

Returns:

Version:

  • SketchUp 2025.0

#current=(environment) ⇒ Sketchup::Environment? (rw)

The #current= method is used to set the current environment in the Environments.

Examples:

environments = Sketchup.active_model.environments
path = 'path/to/environment.hdr'
environment = environments.add('My Environment', path)
environments.current = environment

Parameters:

Returns:

Version:

  • SketchUp 2025.0

Instance Method Details

#[](name) ⇒ Sketchup::Environment?

The #[] method is used to retrieve an Environment by name.

Examples:

environments = Sketchup.active_model.environments
path = 'path/to/environment.hdr'
environment = environments.add('My Environment', path)
result = environments['My Environment']

Parameters:

Version:

  • SketchUp 2025.0

#add(name, path) ⇒ Sketchup::Environment #add(path) ⇒ Sketchup::Environment

Note:

The supported file formats are HDR, EXR and SKE.

The #add method adds an Environment to the Environments.

Overloads:

Returns:

Raises:

  • ArgumentError if the file could not be loaded.

Version:

  • SketchUp 2025.0

#add_observer(arg) ⇒ Boolean

The #add_observer method is used to add an observer to the environments collection.

Examples:

environments = Sketchup.active_model.environments
status = environments.add_observer(observer)

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 2025.0

#each {|environment| ... } ⇒ Environments

The #each method is used to iterate over all the environments in the Environments.

Examples:

environments = Sketchup.active_model.environments
environments.each { |environment| puts environment.name }

Yields:

  • (environment)

Yield Parameters:

Version:

  • SketchUp 2025.0

#length

Alias for #size.

#purge_unusedEnvironments

The #purge_unused method is used to remove unused environments.

Examples:

environments = Sketchup.active_model.environments
environments.purge_unused

Version:

  • SketchUp 2025.0

#remove(environment) ⇒ Boolean

The #remove method removes an Environment from the Environments.

Examples:

environments = Sketchup.active_model.environments
path = 'path/to/environment.hdr'
environment = environments.add('My Environment', path)
environments.remove(environment)

Parameters:

Returns:

  • (Boolean)

    true if the environment was removed, false if it was not found

Version:

  • SketchUp 2025.0

#remove_observer(arg) ⇒ Boolean

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

Examples:

environments = Sketchup.active_model.environments
status = environments.remove_observer(observer)

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 2025.0

#sizeInteger Also known as: #length

The #size method retrieves the number of environments in the Environments.

Examples:

environments = Sketchup.active_model.environments
number = environments.size

Returns:

  • (Integer)

    the number of environments

Version:

  • SketchUp 2025.0