Class: Sketchup::Environment

Inherits:
Entity
  • Object
show all

Overview

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 skydomes, for reflections, and to link the sun to the environment.

Version:

  • SketchUp 2025.0

Instance Method Summary # collapse

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

#descriptionString

The #description method gets the description for an Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.description # Outputs ""

Returns:

Version:

  • SketchUp 2025.0

#description=(description) ⇒ Object

The #description= method sets the description for an Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
environment.description = 'This is an example of description'
puts environment.description # Outputs "This is an example of description"

Parameters:

  • description (String)

    the new description for the environment

Version:

  • SketchUp 2025.0

#linked_sun=(linked_sun) ⇒ Object

The #linked_sun= method is used to set if the Sketchup::Environment is linked to the sun. Shadow lighting is used to create realistic shadows in the scene, enhancing the visual quality.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
environment.linked_sun = true
puts environment.linked_sun? # Outputs true

Parameters:

  • linked_sun (Boolean)

    true if the environment should be linked to the sun, false otherwise

Version:

  • SketchUp 2025.0

#linked_sun?Boolean

The #linked_sun? method is used to determine if the Sketchup::Environment is linked to the sun. This function returns a boolean value indicating whether the shadow light feature is currently enabled in the environment. Shadow lighting is used to create realistic shadows in the scene, enhancing the visual quality.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.linked_sun? # Outputs false

Returns:

  • (Boolean)

    true if the environment is linked to the sun, false otherwise

Version:

  • SketchUp 2025.0

#linked_sun_positionGeom::Point3d

The #linked_sun_position method is used to get the position of the sun linked to the Sketchup::Environment. The position is a Geom::Point3d where the x must be in range [0.0, 1.0] and y must be in range [-1.0, 1.0].

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.linked_sun_position # Outputs Geom::Point3d(0, 0, 0)

Returns:

  • (Geom::Point3d)

    the position of the sun linked to the environment

Version:

  • SketchUp 2025.0

#linked_sun_position=(sun_position) ⇒ Geom::Point3d

The #linked_sun_position= method is used to set the position of the sun linked to the Sketchup::Environment. The position is a Geom::Point3d where the x must be in range [0.0, 1.0] and y must be in range [-1.0, 1.0].

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
environment.linked_sun_position = Geom::Point3d.new(0, 1)
puts environment.linked_sun_position # Outputs Geom::Point3d(0, 1, 0)

Parameters:

  • sun_position (Geom::Point3d)

    the new position of the sun linked to the environment

Returns:

  • (Geom::Point3d)

    the new position of the sun linked to the environment

Version:

  • SketchUp 2025.0

#nameString

The #name method retrieves the name of the Sketchup::Environment. This is the unique internal name of the object which should be used for retrieving the Sketchup::Environment from the model's Sketchup::Environments.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.name # Outputs "Example"

Returns:

  • (String)

    the name of the environment

Version:

  • SketchUp 2025.0

#name=(name) ⇒ String

The #name= method sets the name for an Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
environment.name = 'New Name'
puts environment.name # Outputs "New Name"

Parameters:

  • name (String)

    the new name for the environment

Returns:

  • (String)

    the new name of the environment

Version:

  • SketchUp 2025.0

#pathString

The #path method is used to get the file name of the image used for the Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.path # Outputs 'environment.hdr'

Returns:

  • (String)

    the file name of the image used for the environment

Version:

  • SketchUp 2025.0

#reflection_exposureFloat

Note:

Reflection exposure is a value between 0.0 and 10.0, where 0.0 is no exposure and 10.0 is full exposure.

The #reflection_exposure method is used to get the exposure of the Sketchup::Environment for reflections.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.reflection_exposure # Outputs 1
environment.reflection_exposure = 0.5
puts environment.reflection_exposure # Outputs 0.5

Returns:

  • (Float)

    the exposure of the environment for reflections

Version:

  • SketchUp 2025.0

#reflection_exposure=(reflection_exposure) ⇒ Float

Note:

Reflection exposure is a value between 0.0 and 10.0, where 0.0 is no exposure and 10.0 is full exposure.

The #reflection_exposure= method is used to set the exposure of the Sketchup::Environment for reflections.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.reflection_exposure # Outputs 1
environment.reflection_exposure = 0.5
puts environment.reflection_exposure # Outputs 0.5

Parameters:

  • reflection_exposure (Float)

    the new exposure of the environment for reflections

Returns:

  • (Float)

    the new exposure of the environment for reflections

Version:

  • SketchUp 2025.0

#rotationFloat

The #rotation method is used to get the vertical rotation angle in degrees to apply to the Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.rotation # Outputs 0.0 degrees
environment.rotation = 90.0
puts environment.rotation # Outputs 90.0 degrees

Returns:

  • (Float)

    rotation in degrees

#rotation=(rotation) ⇒ Float

Note:

Rotation is a value between 0.0 and 360.0 degrees.

The #rotation= method is used to set the the vertical rotation angle in degrees to apply to the Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.rotation # Outputs 0.0 degrees
environment.rotation = 90.0
puts environment.rotation # Outputs 90.0 degrees

Parameters:

  • rotation (Float)

Returns:

  • (Float)

Version:

  • SketchUp 2025.0

#skydome_exposureFloat

Note:

Skydome exposure is a value between 0.0 and 20.0, where 0.0 is no exposure and 20.0 is full exposure.

The #skydome_exposure method is used to get the exposure of the Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.skydome_exposure # Outputs 1
environment.skydome_exposure = 0.5
puts environment.skydome_exposure # Outputs 0.5

Returns:

  • (Float)

    the exposure of the environment

Version:

  • SketchUp 2025.0

#skydome_exposure=(skydome_exposure) ⇒ Float

Note:

Skydome exposure is a value between 0.0 and 20.0, where 0.0 is no exposure and 20.0 is full exposure.

The #skydome_exposure= method is used to set the exposure of the Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.skydome_exposure # Outputs 1
environment.skydome_exposure = 0.5
puts environment.skydome_exposure # Outputs 0.5

Parameters:

  • skydome_exposure (Float)

    the new exposure of the environment

Returns:

  • (Float)

    the new exposure of the environment

Version:

  • SketchUp 2025.0

#thumbnailSketchup::ImageRep

The #thumbnail method is used to get the thumbnail image of the Sketchup::Environment.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
thumbnail = environment.thumbnail

Returns:

Version:

  • SketchUp 2025.0

#use_as_skydome=(use_as_skydome) ⇒ Object

The #use_as_skydome= method is used to set if the Sketchup::Environment is used as a skydome.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
environment.use_as_skydome = true
puts environment.use_as_skydome? # Outputs true

Parameters:

  • use_as_skydome (Boolean)

    true if the environment should be used as a skydome, false otherwise

Version:

  • SketchUp 2025.0

#use_as_skydome?Boolean

The #use_as_skydome? method is used to determine if the Sketchup::Environment is used as a skydome.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.use_as_skydome? # Outputs false

Returns:

  • (Boolean)

    true

Version:

  • SketchUp 2025.0

#use_for_reflections=(use_for_reflection) ⇒ Object

The #use_for_reflections= method is used to set if the Sketchup::Environment is used for reflections.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
environment.use_for_reflections = true
puts environment.use_for_reflections? # Outputs true

Parameters:

  • use_for_reflection (Boolean)

    true if the environment should be used for reflections, false otherwise

Version:

  • SketchUp 2025.0

#use_for_reflections?Boolean

The #use_for_reflections? method is used to determine if the Sketchup::Environment is used for reflections.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
puts environment.use_for_reflections? # Outputs false

Returns:

  • (Boolean)

    true if the environment is used for reflections, false otherwise

Version:

  • SketchUp 2025.0

#write_hdr(path) ⇒ String

The #write_hdr method writes the HDR image of the environment to a file in its original file type.

Examples:

model = Sketchup.active_model
environments = model.environments
path = 'path/to/environment.hdr'
environment = environments.add('Example', path)
environment.write_hdr('path/to/directory')

Parameters:

  • path (String)

    the directory where the hdr image should be written

Returns:

  • (String)

    the full path of the written file

Raises:

  • (ArgumentError)

    if the image is invalid.

  • (ArgumentError)

    if the file name is empty.

  • (RuntimeError)

    if the file cannot be written.

Version:

  • SketchUp 2025.0