|
SketchUp Ruby API Reference |
Loop is a low level topology class that will not need to be used often. A Loop is a chain of Edges that bound a Face.
Parent:Entity
Methods: convex?, edges, edgeuses, face, outer?, verticies
Example Code: looptests.rb
Determine if the loop is convex.
status = loop.convex?
status - true if convex, false if not convex
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
loop = face.outer_loop
status = loop.convex?
if (status)
UI.messagebox "Loop is Convex"
else
UI.messagebox "Loop is not Convex"
end
Get an array of the edges that define the loop.
edges = loop.edges
edges - an array of Edge objects 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
loop = face.outer_loop
edges = loop.edges
if (edges)
UI.messagebox edges
else
UI.messagebox "Failure"
end
Get an array of the EdgeUse objects that define this loop.
edgeuses = loop.edgeuse
edgeuses - an array of EdgeUse objects 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
edgeuses = loop.edgeuses
if (edgeuses)
UI.messagebox edgeuses
else
UI.messagebox "Failure"
end
Get the Face object that is bounded by this loop.
face = loop.face
face - a Face 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
loop = face.outer_loop
f = loop.face
if (f)
UI.messagebox f
else
UI.messagebox "Failure"
end
Determine if this is an outer loop. Each face has one outer loop, and will have one loop for each hole.
status = loop.outer?
status - true if the loop is an outer loop, false if it is not an outer loop
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
loop = face.outer_loop
status = loop.outer?
if (status)
UI.messagebox status
else
UI.messagebox "Failure"
end
Get an Array of the vertexes that are part of the loop. The array will be ordered correctly.
vertices = loop.vertices
verticies - an array of Vertex objects 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
loop = face.outer_loop
v = loop.verticesif (v)UI.messagebox velseUI.messagebox "Failure"end
|
SketchUp Ruby API Reference: Loop |
© Google Inc. 2007 sketchup.google.com |