# 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 countEdgesCurveTest centerpoint = Geom::Point3d.new # Create a circle perpendicular to the normal or Z axis vector = Geom::Vector3d.new 0,0,1 vector2 = vector.normalize! model = Sketchup.active_model entities = model.active_entities edgearray = entities.add_circle centerpoint, vector2, 10 edge = edgearray[0] curve = edge.curve number = curve.count_edges if (number) UI.messagebox number else UI.messagebox "Failure" end end def eachEdgeCurveTest centerpoint = Geom::Point3d.new # Create a circle perpendicular to the normal or Z axis vector = Geom::Vector3d.new 0,0,1 vector2 = vector.normalize! model = Sketchup.active_model entities = model.active_entities edgearray = entities.add_circle centerpoint, vector2, 10 edge = edgearray[0] curve = edge.curve curve.each_edge {|e| UI.messagebox e} end def edgesCurveTest centerpoint = Geom::Point3d.new # Create a circle perpendicular to the normal or Z axis vector = Geom::Vector3d.new 0,0,1 vector2 = vector.normalize! model = Sketchup.active_model entities = model.active_entities edgearray = entities.add_circle centerpoint, vector2, 10 edge = edgearray[0] curve = edge.curve edges = curve.edges if (edges) UI.messagebox edges else UI.messagebox "Failure" end end def firstEdgeCurveTest centerpoint = Geom::Point3d.new # Create a circle perpendicular to the normal or Z axis vector = Geom::Vector3d.new 0,0,1 vector2 = vector.normalize! model = Sketchup.active_model entities = model.active_entities edgearray = entities.add_circle centerpoint, vector2, 10 edge = edgearray[7] curve = edge.curve firstedge = curve.first_edge if (firstedge) UI.messagebox firstedge else UI.messagebox "Failure" end end def lastEdgeCurveTest centerpoint = Geom::Point3d.new # Create a circle perpendicular to the normal or Z axis vector = Geom::Vector3d.new 0,0,1 vector2 = vector.normalize! model = Sketchup.active_model entities = model.active_entities edgearray = entities.add_circle centerpoint, vector2, 10 edge = edgearray[7] curve = edge.curve lastedge = curve.last_edge if (lastedge) UI.messagebox lastedge else UI.messagebox "Failure" end end def lengthCurveTest centerpoint = Geom::Point3d.new # Create a circle perpendicular to the normal or Z axis vector = Geom::Vector3d.new 0,0,1 vector2 = vector.normalize! model = Sketchup.active_model entities = model.active_entities edgearray = entities.add_circle centerpoint, vector2, 10 edge = edgearray[7] curve = edge.curve length = curve.length if (length) UI.messagebox length else UI.messagebox "Failure" end end def verticesCurveTest centerpoint = Geom::Point3d.new # Create a circle perpendicular to the normal or Z axis vector = Geom::Vector3d.new 0,0,1 vector2 = vector.normalize! model = Sketchup.active_model entities = model.active_entities edgearray = entities.add_circle centerpoint, vector2, 10 edge = edgearray[7] curve = edge.curve vertices = curve.vertices if (vertices) UI.messagebox vertices else UI.messagebox "Failure" end end if( not file_loaded?("curvetests.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") Curve_menu = plugins_menu.add_submenu("Curve Tests") Curve_menu.add_item("Curve.count_edges") { countEdgesCurveTest } Curve_menu.add_item("Curve.each_edge") { eachEdgeCurveTest } Curve_menu.add_item("Curve.edges") { edgesCurveTest } Curve_menu.add_item("Curve.first_edge") { firstEdgeCurveTest } Curve_menu.add_item("Curve.last_edge") { lastEdgeCurveTest } Curve_menu.add_item("Curve.length") { lengthCurveTest } Curve_menu.add_item("Curve.vertices") { verticesCurveTest } end #----------------------------------------------------------------------------- file_loaded("curvetests.rb")