# Copyright 2004, ODM # Author : ODM # email: odm@aitop.com # http://www.aitop.com # Name : Conee Tool 1.0 (Beta) # Description : A tool to create cone Top # Menu Item : Draw->Cone Top # Usage : 1. Specify base diameter&top diameter and heightof conee. # : 2. Click in model to select location of cone Top 1.0. (future version) # Date : 8/30/2004 # Type : Tool #---------------------------------------------------------------------------- require 'sketchup.rb' #---------------------------------------------------------------------------- def create_cone_top model = Sketchup.active_model entities = model.active_entities group = entities.add_group entities = group.entities model.start_operation "Create Cone" # Encapsulate a single UNDO operation. prompts = ["Base Diameter ", "Top Diameter ","Height","Segments"] # Define prompts in the input box values = [2000.mm, 1000.mm,2000.mm,24] # default values in the input box results = inputbox prompts, values, "Cone Top Dimensions" return if not results # This means that the user canceled the operation base, top,height,segments= results center_base = [0,0,0] # Center of cone base center_top = [0,0,height] # Center of cone base vector = [0,0,1] # Normal Vector radius_base = base/2 # Radius of cone base radius_top=top/2 cone_base = entities.add_circle(center_base, vector, radius_base, segments) cone_top = entities.add_circle(center_top, vector, radius_top, segments) face_base = entities.add_face(cone_base) face_top = entities.add_face(cone_top) ver_base = face_base.vertices ver_top=face_top.vertices lines = [] 0.upto(ver_base.length-1) do |a| lines=entities.add_line(ver_base[a],ver_top[1-a]) entities[entities.length-1].find_faces end model.commit_operation end if( not file_loaded?("conetop1.rb") ) add_separator_to_menu("Draw") UI.menu("Draw").add_item("Cone Top 1.0 ") { create_cone_top } end file_loaded("conetop1.rb")