My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google SketchUp Ruby API

Edge

class

Introduction

SketchUp 6.0+

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

Methods

Edge.all_connectedSketchUp 6.0+

The all_connected method retrieves all of the entities connected to an edge.

Returns:

entities
the entities connected to 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
 # 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

Edge.common_faceSketchUp 6.0+

The common_face method is used to identify a face that is common to two edges.

Arguments:

edge2
The face whose edge you are checking for commonality.

Returns:

face
the Face object that is common to the two edges 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
 # 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

Edge.curveSketchUp 6.0+

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:

curve
returns a Curve or ArcCurve object if it is a curve, false if it is not a curve
 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

Edge.endSketchUp 6.0+

The end method is used to retrieve the Vertex object at the end of the edge.

Returns:

vertex
a Vertex object if successful
 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

Edge.explode_curveSketchUp 6.0+

The explode_curve method is used to explode an edge as though it were an ArcCurve.

Returns:

edge
an exploded edge 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
 # 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

Edge.facesSketchUp 6.0+

The faces method is used to retrieve all of the faces common to the edge.

Returns:

faces
an array of Face objects if successful, false if unsuccessful
 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

Edge.find_facesSketchUp 6.0+

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:

number
the number of faces found
 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

Edge.lengthSketchUp 6.0+

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:

transform
(optional) A Transformation object or array that can be interpreted as a Transformation object.

Returns:

length
the length of the edge in current units
 edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0])
 length = edge.length
 if (length)
   UI.messagebox length
 end

Edge.lineSketchUp 6.0+

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:

line
an array with a Point3d object and a Vector3d object.
 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

Edge.other_vertexSketchUp 6.0+

The other_vertex method is used to find the opposite vertex given one vertex of the edge.

Arguments:

vertex1
One of the Vertex objects associated with the edge.

Returns:

vertex2
the other Vertex object associated with the edge
 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

Edge.reversed_in?SketchUp 6.0+

The reversed_in? method is used to determine if the EdgeUse object is traversed in the corresponding direction as its corresponding edge.

Arguments:

face
The Face object that is bounded by the edge.

Returns:

status
true if the edge is reversed, nil if it is not reversed.
 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

Edge.smooth=SketchUp 6.0+

The smooth= method is used to set the edge to be smooth.

Arguments:

value
true if you want the edge to be smooth, false if you do not want the edge to be smooth.

Returns:

status
true if successful, false if unsuccessful
 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

Edge.smooth?SketchUp 6.0+

The smooth? method is used to retrieve the current smooth setting for an edge.

Returns:

status
true if smooth, false if not smooth
 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

Edge.soft=SketchUp 6.0+

The smooth= method is used to set the edge to be soft.

Arguments:

value
true if you want the edge to be soft, false if you do not want the edge to be soft.

Returns:

status
true if successful, false if unsuccessful
 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

Edge.soft?SketchUp 6.0+

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:

status
true if soft, false if not soft
 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

Edge.splitSketchUp 6.0+

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:

position
A Point3d object whose location is along the edge, or a Float between 0.0 and 1.0 defining how far along the edge to split.

Returns:

edge
the new Edge object that was split off the old one if successful
 # Split a line in half.
 edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0])
 new_edge = edge.split 0.5

Edge.startSketchUp 6.0+

The end method is used to retrieve the Vertex object at the start of the edge.

Returns:

vertex
a Vertex object if successful
 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

Edge.used_by?SketchUp 6.0+

The used_by? method is used to see if an edge is used by a given Face or Vertex.

Arguments:

element
A Vertex or Face object.

Returns:

status
true if the face belongs to the element, false if not.
 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

Edge.verticesSketchUp 6.0+

The vertices method is used to retrieve the vertices on the edge.

Returns:

vertices
an array of Vertex objects
 edge = Sketchup.active_model.entities.add_line([0,0,0],[100,100,0])
 vertices = edge.vertices