|
SketchUp Ruby API Reference |
Curves are edges that are part of a curve. The Curve class contains methods for getting information about a Curve (namely edge information for the curve).
Parent:Entity
Methods: count_edges, each_edge, edges, first_edge, last_edge, length, vertices
Example Code: curvetests.rb
The count_edges method is used to retrieve the number of Edge objects that make up the Curve.
num_edge = curve.count_edges
num_edges - the number of edges in the curve
centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edgearray = entities.add_circle centerpoint, vector2, 10
edge = edgearray[0]
curve = edge.curve
number = curve.count_edges
The each_edge method is used to iterate through all of the Edge objects in the curve.
curve.each_edge {|edge| ...}
edge - a variable that will hold each Edge object as they are found.
centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edgearray = entities.add_circle centerpoint, vector2, 10
edge = edgearray[0]
curve = edge.curve
curve.each_edge {|e| UI.messagebox e}
The edges method is used to retrieve an array of Edge objects that make up the Curve.
edges = curve.edges
edges - an array of Edge objects if successful
centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edgearray = entities.add_circle centerpoint, vector2, 10
edge = edgearray[0]
curve = edge.curve
edges = curve.edges
The first_edge method is used to retrieve the first edge of the curve.
edge = curve.first_edge
edge - the first Edge object in the curve if successful
centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edgearray = entities.add_circle centerpoint, vector2, 10
edge = edgearray[0]
curve = edge.curve
firstedge = curve.first_edge
The last_edge method is used to retrieve the last edge of the curve.
edge = curve.last_edge
edge - the last Edge object in the curve if successful
centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edgearray = entities.add_circle centerpoint, vector2, 10
edge = edgearray[7]
curve = edge.curve
lastedge = curve.last_edge
The length method retrieves the length of the curve.
length = curve.length
length - the length of the curve in current units if successful
centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edgearray = entities.add_circle centerpoint, vector2, 10
edge = edgearray[7]
curve = edge.curve
length = curve.length
The vertices method is used to retrieve the Vertex objects that are on the curve.
verticies = curve.verticies
vertices - an array of Vertex objects if successful
centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edgearray = entities.add_circle centerpoint, vector2, 10
edge = edgearray[7]
curve = edge.curve
vertices = curve.vertices