require 'sketchup.rb' # objective: to make a cylinder(s) and or Elbows # oriented about X,Y & Z axies # can be used with Dome.rb by Frank Wiesner to cap ends if so desired #-------------------------------------------------------------------------- def create_cylinder # The global variables below will allow SU to remember your previous settings $r = 30.cm if not $r $h = 150.cm if not $h $n = 24 if not $n @cyl_orientation = "along Z axis" if not @cyl_orientation # Dialog Box construction cyl_orientation = ["along X axis","along Y axis","along Z axis"] enums = [cyl_orientation.join("|")] prompts = ["Orientation", "Radius", "Height", "No. of segments " ] values = [@cyl_orientation, $r, $h, $n] results = inputbox prompts, values, enums, "Cylinder Properties" return if not results cyl_orientation, $r, $h, $n = results #-------------------------------------------------------------------------- model = Sketchup.active_model model.start_operation "Create Cylinder" entities = model.active_entities group = entities.add_group entities = group.entities #-------------------------------------------------------------------------- if( results[0] == "along X axis" ) circle = entities.add_circle([0,0,0], X_AXIS, $r, $n) base = entities.add_face(circle) base.pushpull -$h end #-------------------------------------------------------------------------- if( results[0] == "along Y axis" ) circle = entities.add_circle([0,0,0], Y_AXIS, $r, $n) base = entities.add_face(circle) base.pushpull -$h end #-------------------------------------------------------------------------- if( results[0] == "along Z axis" ) circle = entities.add_circle([0,0,0], Z_AXIS, $r, $n) base = entities.add_face(circle) base.pushpull -$h end #-------------------------------------------------------------------------- model.commit_operation end #-------------------------------------------------------------------------- if( not file_loaded?("cylinder.rb") ) add_separator_to_menu("Plugins") UI.menu("Plugins").add_item("Cylinder") { create_cylinder } end #-------------------------------------------------------------------------- file_loaded("cylinder.rb")