Class: Sketchup::Environments

Inherits:
Entity
  • Object
show all
Includes:
Enumerable

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 Method Summary # collapse

Methods inherited from Entity

#attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #parent, #persistent_id, #set_attribute, #to_s, #typename, #valid?

Instance Method Details

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

The #[] method is used to retrieve an Sketchup::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:

Returns:

Version:

  • SketchUp 2025.0

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

Note:

The supported image formats are HDR, EXR and SKE.

The #add method adds an Sketchup::Environment to the Sketchup::Environments.

Examples:

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

Parameters:

  • name (String)

    the name of the environment

  • path (String)

    the path to the image used for the environment

Returns:

Raises:

  • ArgumentError if the image 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

#currentSketchup::Environment?

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

Examples:

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

Returns:

Version:

  • SketchUp 2025.0

#current=(environment) ⇒ Sketchup::Environment

The #current= method is used to set the current environment in the Sketchup::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

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

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

Examples:

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

Yields:

  • (environment)

Yield Parameters:

Returns:

Version:

  • SketchUp 2025.0

#purge_unusedSketchup::Environments

The #purge_unused method is used to remove unused environments.

Examples:

environments = Sketchup.active_model.environments
environments.purge_unused

Returns:

Version:

  • SketchUp 2025.0

#remove(environment) ⇒ Boolean

The #remove method removes an Sketchup::Environment from the Sketchup::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 Sketchup::Environments.

Examples:

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

Returns:

  • (Integer)

    the number of environments

Version:

  • SketchUp 2025.0