SketchUp  Ruby API Reference 

Class Index

Method Index

Developers Guide

Examples

Loop class

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

Instance Methods


convex?

Determine if the loop is convex.

Syntax

status = loop.convex? 

Return Value

status - true if convex, false if not convex

 Example

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

 

 


edges 

Get an array of the edges that define the loop.

Syntax

edges = loop.edges 

Return Value

edges - an array of Edge objects if successful

Example

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

 

 


edgeuses 

Get an array of the EdgeUse objects that define this loop.

Syntax

edgeuses = loop.edgeuse 

Return Value

edgeuses - an array of EdgeUse objects if successful

Example 

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

 

 


face 

Get the Face object that is bounded by this loop.

Syntax

face = loop.face 

Return Value

face - a Face object if successful

Example

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

 

 


outer? 

Determine if this is an outer loop. Each face has one outer loop, and will have one loop for each hole.

Syntax

status = loop.outer? 

Return Value

status - true if the loop is an outer loop, false if it is not an outer loop

Example

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

 

 


vertices 

Get an Array of the vertexes that are part of the loop. The array will be ordered correctly.

Syntax

vertices = loop.vertices 

Return Value

verticies - an array of Vertex objects if successful

Example

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.vertices
if (v)
UI.messagebox v
else
UI.messagebox "Failure"
end