# 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 convexLoopTest 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 end def edgesLoopTest 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 end def edgeUsesLoopTest 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 edgeuses = loop.edgeuses if (edgeuses) UI.messagebox edgeuses else UI.messagebox "Failure" end end def faceLoopTest 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 end def outerLoopTest 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 end def verticesLoopTest 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 end if( not file_loaded?("looptests.rb") ) plugins_menu = UI.menu("Plugins") Loop_menu = plugins_menu.add_submenu("Loop Tests") Loop_menu.add_item("Loop.convex?") { convexLoopTest } Loop_menu.add_item("Loop.edges") { edgesLoopTest } Loop_menu.add_item("Loop.edgeuses") { edgeUsesLoopTest } Loop_menu.add_item("Loop.face") { faceLoopTest } Loop_menu.add_item("Loop.outer?") { outerLoopTest } Loop_menu.add_item("Loop.vertices") { verticesLoopTest } end #----------------------------------------------------------------------------- file_loaded("looptests.rb")