The Edge class contains methods modifying and extracting information for edges.
The all_connected method retrieves all of the entities connected to an edge.
Returns:
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.to_s else UI.messagebox "Failure" end
The common_face method is used to identify a face that is common to two edges.
Arguments:
Returns:
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
The curve method is used to get the Curve object that this edge belongs to, if any. Note that if the edge is part of an arc instead of a random curve, then this method will return an ArcCurve object.
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) 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
The end method is used to retrieve the Vertex object at the end of the edge.
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) 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
The explode_curve method is used to explode an edge as though it were an ArcCurve.
Returns:
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] curve = entity1.explode_curve if (curve) UI.messagebox curve else UI.messagebox "Failure" end
The faces method is used to retrieve all of the faces common to the edge.
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) 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
The find_faces method is used to create all of the Faces that can be created with this edge. For example, if you use the API to draw three edges that form a triangle, the face between them will not show up because you've only drawn the edges, but if you call find_faces on one of the edges, the triangle will be filled in.
Returns:
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 "I created " + number.to_s + " faces." else UI.messagebox "Failure" end
The length method is used to retrieve the length of an edge in current
units.
You can pass in an optional Transformation (or an array that can represent a
transformation), to correct for a parent group's transformation. For example,
if an edge is inside of a group that is scaled to 200%, the length method
will return the unscaled length of the edge. So by passing a 200%
transformation object to this method, you can account for that to get the
"visual" length of the edge.
Arguments:
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) length = edge.length if (length) UI.messagebox length end
The line method is used to retrieve the line defined by the edge. Lines in SketchUp aren't visible entities but geometric constructs represented by an Array with a Point3d and a Vector3d. See the Geom module and the Array class for more information on lines.
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) # Returns a 3D ray line = edge.line if (line) UI.messagebox line else UI.messagebox "Failure" end
The other_vertex method is used to find the opposite vertex given one vertex of the edge.
Arguments:
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) # 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
The reversed_in? method is used to determine if the EdgeUse object is traversed in the corresponding direction as its corresponding edge.
Arguments:
Returns:
model = Sketchup.active_model entities = model.active_entities pts = [] pts[0] = [0, 0, 0] pts[1] = [9, 0, 0] pts[2] = [9, 9, 0] pts[3] = [0, 9, 0] # Add the face to the entities in the model face = entities.add_face pts edge = face.edges[0] begin # When the geometry is a 2d rectangle with four edges, the face itself # is entities[4] status = edge.reversed_in? face rescue UI.messagebox $!.message end
The smooth= method is used to set the edge to be smooth.
Arguments:
Returns:
entity = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) # 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
The smooth? method is used to retrieve the current smooth setting for an edge.
Returns:
entity = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) # 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
The smooth= method is used to set the edge to be soft.
Arguments:
Returns:
entity = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) # 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
The soft? method is used to retrieve the current smooth setting for an edge. A soft edge is automatically hidden unless it is shows up as a profile edge.
Returns:
entity = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) # 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
The split method is used to to split an edge into to or more distinct
edges. If a Point3d is given, it must be a point that is on the Edge.
If a Float is given, it is a number between 0 and 1 that gives the
relative position along the edge at which to split it. For example,
edge.split(0.5) will split the Edge at its midpoint. This split position
is measured from the Edge.start.
Returns the new Edge that was created as a result of splitting this one.
Arguments:
Returns:
# Split a line in half. edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) new_edge = edge.split 0.5
The end method is used to retrieve the Vertex object at the start of the edge.
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) 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
The used_by? method is used to see if an edge is used by a given Face or Vertex.
Arguments:
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) # Returns a vertex vertex = edge.start # Check to see if the edge is used by the Vertex. status = edge.used_by? vertex if (status) UI.messagebox status else UI.messagebox "Failure" end
The vertices method is used to retrieve the vertices on the edge.
Returns:
edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0]) vertices = edge.vertices