Drawingelement

class Drawingelement

Parent: Entity | Class Index
Methods: bounds, erase!, hidden=, hidden?, layer, layer=, material, mat erial=, visible=, visible? |
Sample Code: drawingelementtests.rb |

DrawingElement is a base class for an item in the model that can be displayed. These items include edges, contruction 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.

Instance Methods

bounds
The bounds method is used to retrieve the bounding box for an drawing element.
Syntax:
boundingbox = drawingelement.bounds
Arguments:
Return Value:
boundingbox - A BoundingBox object if successful
Comments:
Example:

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 and because face
# sub-classes DrawingElement.
boundingbox = face.bounds

erase!
The erase! method is used to erase an element from the model.
Syntax:
status = drawingelement.erase!
Arguments:
Return Value:
status - true if successful, false if unsuccessful
Comments:
Erasing an Edge also erases all of the Face objects that use the Edge.
Example:

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!

hidden=
The hidden= method is used to set the hidden status for an element.
Syntax:
status = drawingelement.hidden = true | false
Arguments:
true | false - true if you want to hide the element, false if you do not want to hide the element
Return Value:
status - true if the element has been hidden, false if the element has not been hidden.
Comments:
Example:

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

hidden?
The hidden? method is used to determine if the element is hidden.
Syntax:
status = drawingelement.hidden?
Arguments:
Return Value:
status - true if hidden, false if not hidden
Comments:
Hidden elements are still in the model, but they are not displayed.
Example:

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?

layer
The layer method is used to retrieve the Layer object of the drawing element.
Syntax:
layer = drawingelement.layer
Arguments:
Return Value:
layer - a layer object if successful
Comments:
Example:

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

layer=
The layer= method is used to set the layer for the drawing element.
Syntax:
layer = drawingelement.layer = layer | "layername"
Arguments:
layer - a layer number layername - a layer name
Return Value:
layer - the new Layer object if successful
Comments:
An exception is raised if you give a string that doesn't match any layer name.
Example:

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 = layers.add "joe"
# Put the face on the joe layer (instead of layer 0)
newlayer = face.layer=layer

material
The material method is used to retrieve the material for the drawing element.
Syntax:
material = drawingelement.material
Arguments:
Return Value:
material - the Material object if successful
Comments:
Example:

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

material=
The material= method is used to set the material for the drawing element.
Syntax:
material = drawingelement.material = material | "materialname" | color | "colorname"
Arguments:
material - a material object materialname - the name of a material color - a color object colorname - the name of a color
Return Value:
material - the new Material object if successful
Comments:
Example:

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 = materials.add "Joe"
begin
# Returns nil if not successful, path if successful. Should return a texture object
m.texture="c:\\Program Files\\@Last Software\\SketchUp 4\\Materials\\Carpet.jpg"
rescue
UI.messagebox $!.message
end
# You will see the material applied when you reverse the box's faces
material = face.material=m

visible=
The visible= method is used to set the visible status for an element. This method performs an opposite function to the hidden= method.
Syntax:
status = drawingelement.visible = true | false
Arguments:
true | false - true if you want to hide the element, false if you do not want to hide the element
Return Value:
status - true if the element has been hidden, false if the element has not been hidden.
Comments:
Example:

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

visible?
The visible? method is used to determine if the element is visible. This method performs an opposite function to the hidden? method.
Syntax:
status = drawingelement.visible?
Arguments:
Return Value:
status - true if hidden, false if not hidden
Comments:
Example:

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.visible?