# 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' #----------------------------------------------------------------------------- # Have to manually create a section plane in a .skp file and traverse the # entities array to get a section plane. There is not currently any way to # create a SectionPlane through Ruby. So, to test this I manully draw a line # and then use the section plane tool on the line. The section plane will # be the second entity in the entities array (entities[1]). def getPlaneSectionPlaneTest model = Sketchup.active_model entities = model.active_entities UI.messagebox entities sp = entities[1] plane = sp.get_plane if (plane) UI.messagebox plane else UI.messagebox "Failure" end end def setPlaneSectionPlaneTest newplane = [Geom::Point3d.new(-10, 0 ,0), Geom::Vector3d.new(1,0,0)] model = Sketchup.active_model entities = model.active_entities UI.messagebox entities sp = entities[1] plane = sp.get_plane if (plane) UI.messagebox plane else UI.messagebox "Failure" end plane = sp.set_plane newplane if (plane) UI.messagebox plane else UI.messagebox "Failure" end end if( not file_loaded?("sectionplanetests.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") SectionPlaneTest_menu = plugins_menu.add_submenu("SectionPlane Tests") SectionPlaneTest_menu.add_item("SectionPlane.get") { getPlaneSectionPlaneTest } SectionPlaneTest_menu.add_item("SectionPlane.set") { setPlaneSectionPlaneTest } end #----------------------------------------------------------------------------- file_loaded("sectionplanetests.rb")