class Edge

Parent: Drawingelement | Class Index
Methods:all_connected, common_face, curve, end, faces, find_faces, length, line, other_vertex, reversed_in?, smooth=, smooth?, soft=, soft?, split, start, used_by?, verticies |
Sample Code: edgetests.rb |

The Edge class contains methods modifying and extracting information for edges.

Instance Methods

all_connected
The all_connected method retrieves all of the entities connected to an edge.
Syntax:
entities = edge.all_connected
Arguments:
Return Value:
entities - the entities connected to the edge
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 # I just happen to know that the second and third entities in the # entities objects are edges. entity1 = entities[1] entity2 = entities[2] edges = entity1.all_connected if (edges) UI.messagebox edges else UI.messagebox "Failure" end

common_face
The common_face method is used to identify a face that is common to two edges.
Syntax:
face = edge1.common_face edge2
Arguments:
edge2 - the face whose edge you are checking for commonality
Return Value:
face - the Face object that is common to the two edges 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 # I know that the second and third entity objects are edges entity1 = entities[1] entity2 = entities[2] UI.messagebox entity1 UI.messagebox entity2 face = entity1.common_face entity2 if (face) UI.messagebox face else UI.messagebox "Failure: No Common Face" end

curve
The curve method is used to determine if an edge to see if it is a ArcCurve object.
Syntax:
arccurve = edge.curve
Arguments:
Return Value:
arccurve - returns an ArcCurve object if it is a curve, false if it is not a curve
Comments:
Example:
curve = edge.curve if (curve) # if it is a curve, display a pointer to the curve UI.messagebox curve else UI.messagebox "Failure: Not a Curve" end

end
The end method is used to retrieve the Vertex object at the end of the edge.
Syntax:
vertex = edge.end
Arguments:
Return Value:
vertex - a Vertex object if successful
Comments:
Example:
vertex = edge.end if (vertex) # display a pointer to the Vertex UI.messagebox vertex else UI.messagebox "Failure" end point = vertex.position # Let's get the Point3d of the vertex if (point) UI.messagebox point else UI.messagebox "Failure" end

faces
The faces method is used to retrieve all of the faces common to the edge.
Syntax:
faces edge.faces
Arguments:
Return Value:
faces - an array of Face objects if successful, false if unsuccessful
Comments:
Example:
faces = edge.faces if (faces) # Display the pointer to the first face returned in the array UI.messagebox faces[0] else UI.messagebox "Failure: No Faces Found" end

find_faces
The find_faces method is used to find all Face objects that were created with this edge
Syntax:
number = edge.find_faces
Arguments:
Return Value:
number - the number of faces found
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 # I just happen to know that the second entity in the # entities objects is an edge. entity1 = entities[1] # Getting zero. number = entity1.find_faces if (number) UI.messagebox number else UI.messagebox "Failure" end

length
The length method is used to retrieve the length of an edge in current units.
Syntax:
length = edge.length
Arguments:
Return Value:
length - the length of the edge in current units
Comments:
Example:
length = edge.length if (length) UI.messagebox length

line
The line method is used to retrieve the line defined by the edge.
Syntax:
line = edge.line
Arguments:
Return Value:
line - an array with a Point3d object and a Vector3d object.
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 # I know that the second and entity object is an edge entity1 = entities[1] # Returns a 3d ray line = edge.line if (line) # Result is (100" 0", 0") (0.0, 1.0, 0.0) UI.messagebox line else UI.messagebox "Failure" end

other_vertex
The other_vertex method is used to find the opposite vertex given one vertex of the edge.
Syntax:
vertex2 = edge.other_vertex vertex1
Arguments:
vertex1 - one of the Vertex objects associated with the edge
Return Value:
vertex2 - the other Vertex object associated with the edge
Comments:
Example:
# Get the end vertex of an edge vertex = edge.end # Should find the starting vertex othervertex = edge.other_vertex vertex if (othervertex) UI.messagebox othervertex else UI.messagebox "Failure" end # The Point3d for the vertex point = othervertex.position if (point) UI.messagebox point else UI.messagebox "Failure" end

reversed_in?
The reversed_in? method is used to determine if the EdgeUse object is traversed in the corresponding direction as its corresponding edge.
Syntax:
status = edge.reversed_in? face
Arguments:
face - the Face object that is bounded by the edge.
Return Value:
status - true if the edge is reversed, nil if it is not reversed.
Comments:
Example:
begin # When the geometry is a 2d rectangle with four edges, the face itself # is entities[4] status = entity.reversed_in? entities[4] rescue UI.messagebox $!.message end if (status) UI.messagebox status else UI.messagebox "Failure"

smooth=
The smooth= method is used to set the edge to be smooth.
Syntax:
status = entity.smooth= value
Arguments:
value - true if you want the edge to be smooth, false if you do not want the edge to be smooth
Return Value:
status - true if successful, false if unsuccessful
Comments:
Example:
# Examine the current smooth setting on an edge status = entity.smooth? if (status) # If true, set it to false UI.messagebox "Smooth" status = entity.smooth="false" else # if false, set it to true UI.messagebox 'Not Smooth" status = entity.smooth="true" end

smooth?
The smooth? method is used to retrieve the current smooth setting for an edge.
Syntax:
status = edge.smooth?
Arguments:
Return Value:
status - true if smooth, false if not smooth
Comments:
Example:
# Examine the current smooth setting on an edge status = entity.smooth? if (status) # If true, set it to false UI.messagebox "Smooth" status = entity.smooth="false" else # if false, set it to true UI.messagebox 'Not Smooth" status = entity.smooth="true" end

soft=
The smooth= method is used to set the edge to be soft.
Syntax:
status = entity.soft = value
Arguments:
value - true if you want the edge to be soft, false if you do not want the edge to be soft
Return Value:
status - true if successful, false if unsuccessful
Comments:
Example:
# Examine the current soft setting on an edge status = entity.soft? if (status) # If true, set it to false UI.messagebox "Soft" status = entity.soft="false" else # if false, set it to true UI.messagebox 'Not Soft" status = entity.soft="true" end

soft?
The soft? method is used to retrieve the current smooth setting for an edge.
Syntax:
status = edge.soft?
Arguments:
Return Value:
status - true if soft, false if not soft
Comments:
Example:
# Examine the current soft setting on an edge status = entity.soft? if (status) # If true, set it to false UI.messagebox "Soft" status = entity.soft="false" else # if false, set it to true UI.messagebox 'Not Soft" status = entity.soft="true" end

split
The split method is used to to split an edge into to or more distinct edges.
Syntax:
edge = edge.split position
Arguments:
position - a Point3d object whose location is along the edge
Return Value:
edge - an Edge 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 # I just happen to know that the second entity in the # entities objects is an edge. entity = entities[1] vertex = entity.end # Get a Point3d for the end vertex position = vertex.position UI.messagebox position # Get the y value (the only value that changes between beginning and # end verticies) y = position.y # Returing 8' 4" or 100" # Divide the y value by 2 to get a new y value that is 1/2 the distance between # start and end verticies newy = y / 2 # Put the new y position in the Point3d object UI.messagebox position position.y=newy # Split the edge with the new Point3d object (should get 2 edges on # right-hand side of square) edge = entity.split position if (edge) UI.messagebox edge else UI.messagebox "Failure" end

start
The end method is used to retrieve the Vertex object at the start of the edge.
Syntax:
vertex = edge.start
Arguments:
Return Value:
vertex - a Vertex object if successful
Comments:
Example:
vertex = edge.start if (vertex) # display a pointer to the Vertex UI.messagebox vertex else UI.messagebox "Failure" end point = vertex.position # Let's get the Point3d of the vertex if (point) UI.messagebox point else UI.messagebox "Failure" end

used_by?
The used_by? method is used to see if a vertex is used by an edge.
Syntax:
status = edge.usedby? vertex
Arguments:
vertex - a Vertex object
Return Value:
status - true if the vertex belongs to the edge, false if the vertex does not belong to the edge
Comments:
Example:
# Returns a vertex vertex = entity1.start # Check to see if the vertex is used by the edge status = entity1.used_by? vertex if (status) UI.messagebox status else UI.messagebox "Failure" end

vertices
The vertices method is used to retrieve an Array object consisting of the two vertices for an edge.
Syntax:
vertices = edge.vertices
Arguments:
Return Value:
vertices - an Array object of two Vertex objects
Comments:
Example:
vertices = entity1.vertices if (vertices) UI.messagebox vertices else UI.messagebox "Failure" end # Examine the first vertex vertex = vertices[0] point = vertex.position UI.messagebox point