|
SketchUp Ruby API Reference |
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.
Parent:Entity
Methods: bounds, cast_shadows= , cast_shadows?, erase! ,hidden= ,hidden?, layer, layer=, material, material=, receive_shadows=, receive_shadows? , visible=, visible?
Example Code: drawingelementtests.rb
The bounds method is used to retrieve the bounding box for an drawing element.
boundingbox = drawingelement.bounds
boundingbox - A BoundingBox object if successful
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
The cast_shadows= method is used to set the Drawingelement to cast shadows.
status = cast_shadows= true | false
true | false - true if you want the Drawingelement object to cast shadows, false if you do not want the Drawingelement object to cast shadows.
status - true if successful, false if unsuccessful.
The cast_shadows? method is used to determine if the Drawingelement is casting shadows.
status = cast_shadows?
status - true if the Drawingelement is casting shadows, false if unsuccessful.
The erase! method is used to erase an element from the model.
status = drawingelement.erase!
status - true if successful, false if unsuccessful
Erasing an Edge also erases all of the Face objects that use the Edge.
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!
The hidden= method is used to set the hidden status for an element.
status = drawingelement.hidden = true | false
true | false - true if you want to hide the element, false if you do not want to hide the element
status - true if the element has been hidden, false if the element has not been hidden.
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 ptsUI.messagebox "Click OK to Hide the Box"status = face.hidden=true
The hidden? method is used to determine if the element is hidden.
status = drawingelement.hidden?
status -true if hidden, false if not hidden
Hidden elements are still in the model, but they are not displayed.
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?
The layer method is used to retrieve the Layer object of the drawing element.
layer = drawingelement.layer
layer - a layer object if successful
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 ptslayer = face.layer
The layer= method is used to set the layer for the drawing element.
layer = drawingelement.layer = layer | "layername"
layer - a layer number
layername - a layer name
layer - the new Layer object if successful
An exception is raised if you give a string that doesn't match any layer name.
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 layerlayer = layers.add "joe"# Put the face on the joe layer (instead of layer 0)newlayer = face.layer=layer
The material method is used to retrieve the material for the drawing element.
material = drawingelement.material
material - the Material object if successful
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
The material= method is used to set the material for the drawing element.
Syntax
material = drawingelement.material = material | "materialname" | color | "colorname"
material - a material object
materialname - the name of a material
color - a color object
colorname - the name of a color
material - the new Material object if successful
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 ptsm = materials.add "Joe"begin# Returns nil if not successful, path if successful. Should return a texture objectm.texture="c:\\Program Files\\@Last Software\\SketchUp 4\\Materials\\Carpet.jpg"rescueUI.messagebox $!.messageend# You will see the material applied when you reverse the box's facesmaterial = face.material=m
The receive_shadows= method is used to set the Drawingelement to receive shadows.
status = receive_shadows= true | false
true | false - true if you want the Drawingelement object to receive shadows, false if you do not want the Drawingelement object to receive shadows.
status - true if successful, false if unsuccessful.
The receive_shadows? method is used to determine if the Drawingelement is receiving shadows.
status = receive_shadows?
status - true if the Drawingelement is receiving shadows, false if unsuccessful.
The visible= method is used to set the visible status for an element. This method performs an opposite function to the hidden= method.
status = drawingelement.visible = true | false
true | false - true if you want to hide the element, false if you do not want to hide the element
status - true if the element has been hidden, false if the element has not been hidden.
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
The visible? method is used to determine if the element is visible. This method performs an opposite function to the hidden? method.
status = drawingelement.visible?
status - true if hidden, false if not hidden
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 ptsstatus = face.visible?
|
SketchUp Ruby API Reference: Drawingelement |
© Google Inc. 2007 sketchup.google.com |