123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::Drawingelement

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

Overview

Drawingelement is a base class for an item in the model that can be displayed. These items include edges, construction points, construction lines, and images. Arc curves and arcs are not included because they are not drawing elements by themselves, but are a composition of edges.

Version:

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

#casts_shadows=(casts) ⇒ Boolean (rw)

The casts_shadows= method is used to set the Drawingelement to cast shadows.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 100]
pts[1] = [width, 0, 100]
pts[2] = [width, depth, 100]
pts[3] = [0, depth, 100]
# Add the face to the entities in the model.
face = entities.add_face pts

# Make the face not cast shadows.
status = face.casts_shadows = false
UI.messagebox status.to_s

Parameters:

  • casts (Boolean)

    true if you want the Drawingelement object to cast shadows, false if you do not want the Drawingelement object to cast shadows.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#casts_shadows?Boolean (rw)

The casts_shadows? method is used to determine if the Drawingelement is casting shadows.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
status = face.casts_shadows?
UI.messagebox status.to_s

Version:

  • SketchUp 6.0

#hidden=(hidden) ⇒ Boolean (rw)

The hidden= method is used to set the hidden status for an element.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
UI.messagebox "Click OK to Hide the Box"
status = face.hidden = true

Parameters:

  • hidden (Boolean)

    true if you want to hide the element, false if you do not want to hide the element.

Returns:

  • (Boolean)

    true if the element has been hidden, false if the element has not been hidden.

Version:

  • SketchUp 6.0

#hidden?Boolean (rw)

The hidden? method is used to determine if the element is hidden.

Hidden elements are still in the model, but they are not displayed.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
status = face.hidden?
UI.messagebox "hidden? " + status.to_s

Version:

  • SketchUp 6.0

#layerSketchup::Layer (rw)

The layer method is used to retrieve the Layer object of the drawing element.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
layer = face.layer

Returns:

Version:

  • SketchUp 6.0

#layer=(layer) ⇒ Sketchup::Layer, String (rw)

The layer= method is used to set the layer for the drawing element.

An exception is raised if you give a string that doesn’t match any layer name.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
# Add a layer
layer = Sketchup.active_model.layers.add "joe"
# Put the face on the joe layer (instead of layer 0)
newlayer = face.layer = layer

Parameters:

Returns:

Version:

  • SketchUp 6.0

#materialSketchup::Material (rw)

The material method is used to retrieve the material for the drawing element.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
material = face.material

Returns:

Version:

  • SketchUp 6.0

#material=(material) ⇒ Sketchup::Material, ... (rw)

The material= method is used to set the material for the drawing element.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
m = model.materials.add "Joe"
begin
  # Returns nil if not successful, path if successful.
  # Should return a texture object.
  m.texture = "c:\\My Textures\\Carpet.jpg"
rescue
  UI.messagebox $!.message
end
# You will see the material applied when you reverse the box's faces
material = face.material = m

Parameters:

Returns:

Version:

  • SketchUp 6.0

#receives_shadows=(receive) ⇒ Boolean (rw)

The receive_shadows= method is used to set the Drawingelement to receive shadows.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 100]
pts[1] = [width, 0, 100]
pts[2] = [width, depth, 100]
pts[3] = [0, depth, 100]
# Add the face to the entities in the model.
face = entities.add_face pts

# Make the face not receive shadows.
status = face.receives_shadows = false
UI.messagebox status.to_s

Parameters:

  • receive (Boolean)

    true if you want the Drawingelement object to receive shadows, false if not.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#receives_shadows?Boolean (rw)

The receive_shadows? method is used to determine if the Drawingelement is receiving shadows.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
status = face.receives_shadows?
UI.messagebox status.to_s

Version:

  • SketchUp 6.0

#visible=(visibility) ⇒ Boolean (rw)

The visible= method is used to set the visible status for an element. This method performs an opposite function to the hidden= method.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
UI.messagebox "Click OK to Hide the Box"
status = face.visible = false

Parameters:

  • visibility (Boolean)

    true if you want to hide the element, false if not

Returns:

  • (Boolean)

    true if the element has been hidden, false if the element has not been hidden.

Version:

  • SketchUp 6.0

#visible?Boolean (rw)

The visible? method is used to get the visible status for an element.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
UI.messagebox "Click OK to Hide the Box"
face.visible = false
UI.messagebox "Is the face visible? " + face.visible?.to_s

Version:

  • SketchUp 6.0

Instance Method Details

#boundsGeom::BoundingBox

The #bounds method is used to retrieve the ::Geom::BoundingBox bounding a Drawingelement.

For a Edge, ComponentInstance and most other Drawingelements, the boundingbox follows the coordinate system the drawing element is placed in. For ComponentDefinition, the box bounds the contents of the component and follows the component’s own internal coordinate system.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
# Remember, anything that can be displayed, such as a face, is also
# a Drawingelement. So I can call bounds on a face because Face
# is a sub-class of Drawingelement.
boundingbox = face.bounds

Version:

  • SketchUp 6.0

#erase!nil

Note:

When erasing multiple elements, it’s faster to use Entities#erase_entities and erase in bulk than to iterate individual drawing elements calling erase!.

The #erase! method is used to erase an element from the model.

Erasing an Edge also erases all of the Face objects that use the Edge.

Examples:

depth = 100
width = 100
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]
# Add the face to the entities in the model
face = entities.add_face pts
status = face.erase!

Raises:

  • (ArgumentError)

    if the drawing element is an instance used by Model#active_path.

Version:

  • SketchUp 6.0