# Name : Pushpull_z # Description : Extrudes a face along Z axis, not along the face normal # Author : Didier Bur # Usage : select a face, select from the Plugins menu, enter height and here you go # Date : 03.Jul.2oo4 # Type : tool require 'sketchup.rb' def line_to_wall model = Sketchup.active_model model.start_operation "Line2wall" entities = model.active_entities ss = model.selection if ss.empty? UI.messagebox("No selection.") return nil end if not ss.first.kind_of? Sketchup::Edge UI.messagebox("Please select a line.") return nil end if ss.length > 1 UI.messagebox("Please select only one line.") return nil end prompts = ["Wall width", "Wall height "] value = [25.cm,250.cm] results = inputbox prompts, value, "Wall parameters" return if not results # This means that the user canceld the operation width, height = results pts = ss[0].vertices # copy the selected line i = 0 pts2 = [] pts.each do |pt| pts2[i] = pt.position + [0 , 0 , results[1]] i = i +1 end line_copy = entities.add_line pts2 pts_copy = line_copy.vertices # create lines between pairs of vertices of each face i = 0 j = 0 #0.upto(pts.length - 2) do |new_line| # #new_face = entities.add_face(pts[i], pts[i + 1], pts_copy[i + 1], pts_copy[i]) # new_line = entities.add_line(pts[i], pts_copy[i]) # i = i + 1 #end # of upto # close the inner wall new_face = entities.add_face(pts[0], pts_copy[0], pts_copy[1], pts[1]) new_face.pushpull width model.commit_operation end # of def if( not file_loaded?("line2wall.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") # To add an item to a menu, you identify the menu, and then # provide a title to display and a block to execute. In this case, # the block just calls the create_box function UI.menu("Plugins").add_item("Line to wall") { line_to_wall } end #----------------------------------------------------------------------------- file_loaded("line2wall.rb")