# Copyright 2005, @Last Software, Inc. # This software is provided as an example of using the Ruby interface # to SketchUp. # Permission to use, copy, modify, and distribute this software for # any purpose and without fee is hereby granted, provided that the above # copyright notice appear in all copies. # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #----------------------------------------------------------------------------- require 'sketchup.rb' #----------------------------------------------------------------------------- def commonEdgeVertexTest 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 # Just happen to know that first item in entities is an edge edge = entities[0] # returns array of verticies that make up the line verticies = edge.vertices vertex1 = verticies[0] vertex2 = verticies[1] edge = vertex1.common_edge vertex2 if (edge) UI.messagebox edge else UI.messagebox "Failure" end end def curveInteriorVertexTest 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 # Just happen to know that first item in entities is an edge edge = entities[0] # returns array of verticies that make up the line verticies = edge.vertices vertex1 = verticies[0] status = vertex1.curve_interior? if (status) UI.messagebox status else #returns nil if vertex is not on interior of a Curve UI.messagebox "Failure" end end def edgesVertexTest 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 # Just happen to know that first item in entities is an edge edge = entities[0] # returns array of verticies that make up the line verticies = edge.vertices vertex1 = verticies[0] edges = vertex1.edges if (edges) UI.messagebox edges else UI.messagebox "Failure" end end def facesVertexTest 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 # Just happen to know that first item in entities is an edge edge = entities[0] # returns array of verticies that make up the line verticies = edge.vertices vertex1 = verticies[0] faces = vertex1.faces if (faces) UI.messagebox faces else UI.messagebox "Failure" end end def loopsVertexTest 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 # Just happen to know that first item in entities is an edge edge = entities[0] # returns array of verticies that make up the line verticies = edge.vertices vertex1 = verticies[0] loops = vertex1.loops if (loops) UI.messagebox loops else UI.messagebox "Failure" end end def positionVertexTest 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 # Just happen to know that first item in entities is an edge edge = entities[0] # returns array of verticies that make up the line verticies = edge.vertices vertex1 = verticies[0] position = vertex1.position if (position) UI.messagebox position else UI.messagebox "Failure" end end def usedVertexTest 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 # Just happen to know that first item in entities is an edge edge = entities[0] # returns array of verticies that make up the line verticies = edge.vertices vertex1 = verticies[0] status = vertex1.used_by? face if (status) UI.messagebox status else UI.messagebox "Failure" end end if( not file_loaded?("vertextests.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") Vertex_menu = plugins_menu.add_submenu("Vertex Tests") Vertex_menu.add_item("Vertex.common_edge") { commonEdgeVertexTest } Vertex_menu.add_item("Vertex.curve_interior?") { curveInteriorVertexTest } Vertex_menu.add_item("Vertex.edges") { edgesVertexTest } Vertex_menu.add_item("Vertex.faces") { facesVertexTest } Vertex_menu.add_item("Vertex.curve_interior?") { curveInteriorVertexTest } Vertex_menu.add_item("Vertex.loops") { loopsVertexTest } Vertex_menu.add_item("Vertex.position") { positionVertexTest } Vertex_menu.add_item("Vertex.used_by?") { usedVertexTest } end #----------------------------------------------------------------------------- file_loaded("vertextests.rb")