Curve class
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
Instance Methods
count_edges
The count_edges
method is used to retrieve the number of Edge objects that make up the
Curve.
Syntax
num_edge = curve.count_edges
Return Value
num_edges - the number of edges in the
curve
Example
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
each_edge
The each_edge
method is used to iterate through all of the Edge objects in the curve.
Syntax
curve.each_edge {|edge| ...}Return Value
edge - a variable that will hold
each Edge object as they are found.
Example
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}
edges
The edges
method is used to retrieve an array of Edge objects that
make up the Curve.
Syntax
edges = curve.edges
Return Value
edges - an array of Edge objects if successful
Example
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
first_edge
The first_edge
method is used to retrieve the first edge of the curve.
Syntax
edge = curve.first_edge
Return Value
edge - the first Edge object in the curve
if successful
Example
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
last_edge
The last_edge
method is used to retrieve the last edge of the curve.
Syntax
edge = curve.last_edge
Return Value
edge - the last Edge object in the curve
if successful
Example
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
length
The length
method retrieves the length of the curve.
Syntax
length = curve.length
Return Value
length - the length of the curve in current
units if successful
Example
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
vertices
The vertices
method is used to retrieve the Vertex objects that are on the curve.
Syntax
verticies = curve.verticies
Return Value
vertices - an array of Vertex objects
if successful
Example
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