Hello,
I am completely new to Ruby and not sure if this is the best place to ask the following beginners question. In the Sketchup API reference there is the following 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
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
#-----------------------------------------------------------------------------
When I type entities[0].class in the console the response is Sketchup::ComponentInstance
What exactly is going on? I thought I only created 4 edges and one face but there is also a ComponentInstance defined. What exactly is a ComponentInstance and why is it defined? as there is no Component present. How does Sketchup iterate through the entities array?
So :
entities[0].class Sketchup::ComponentInstance
entities[1].class Sketchup::Edge
entities[2].class Sketchup::Edge
entities[3].class Sketchup::Edge
entities[4].class Sketchup::Edge
entities[5].class Sketchup::Face