# 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 edgeEdgeUseTest 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 edgeuse = edgeuses[0] edge = edgeuse.edge if (edge) UI.messagebox edge else UI.messagebox "Failure" end end def faceEdgeUseTest 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 edgeuse = edgeuses[0] face = edgeuse.face if (face) UI.messagebox face else UI.messagebox "Failure" end end def loopEdgeUseTest 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 edgeuse = edgeuses[0] loop = edgeuse.loop if (loop) UI.messagebox loop else UI.messagebox "Failure" end end def nextEdgeUseTest 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 edgeuse = edgeuses[0] eunext = edgeuse.next if (eunext) UI.messagebox eunext else UI.messagebox "Failure" end end def partnersEdgeUseTest 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 pts2 = [] pts2[0] = [100, 0, 0] pts2[1] = [200, 0, 0] pts2[2] = [200, 100, 0] pts2[3] = [100,100,0] # Add the face to the entities in the model face2 = entities.add_face pts2 loop = face.outer_loop edgeuses = loop.edgeuses edgeuse = edgeuses[1] p = edgeuse.partners if (p) UI.messagebox p else UI.messagebox "Failure" end end def previousEdgeUseTest 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 edgeuse = edgeuses[0] euprevious = edgeuse.previous if (euprevious) UI.messagebox euprevious else UI.messagebox "Failure" end end def reversedEdgeUseTest 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 edgeuse = edgeuses[0] status = edgeuse.reversed? if (status) UI.messagebox status else UI.messagebox "Failure" end end if( not file_loaded?("edgeusetests.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") EdgeUse_menu = plugins_menu.add_submenu("EdgeUse Tests") EdgeUse_menu.add_item("EdgeUse.edge") { edgeEdgeUseTest } EdgeUse_menu.add_item("EdgeUse.face") { faceEdgeUseTest } EdgeUse_menu.add_item("EdgeUse.loop") { loopEdgeUseTest } EdgeUse_menu.add_item("EdgeUse.next") { nextEdgeUseTest } EdgeUse_menu.add_item("EdgeUse.partners") { partnersEdgeUseTest } EdgeUse_menu.add_item("EdgeUse.previous") { previousEdgeUseTest } EdgeUse_menu.add_item("EdgeUse.reversed?") { reversedEdgeUseTest } end #----------------------------------------------------------------------------- file_loaded("edgeusetests.rb")