src/jwm_draw_framing/draw_framing_main_v0.56.rb
#--------------------------------
## The activate method is called by SketchUp when the tool is first selected, or when R-click menu is called
## it is a good place to put most of your initialization
The activate method is called by SketchUp when the tool is first selected, or when R-click menu is called
it is a good place to put most of your initialization
The activate method is called by SketchUp when the tool is first selected or when R - click menu is called it is a good place to put most of your initialization
def activate
		if @@suspended
			self.resume(nil )
		end
		@n_size[12] = @@custom_size
			if !@chosen_size 
				@chosen_size = @@size_index 
			end
		s_label = @n_size[@chosen_size]
		@cursor_text = "\n\n" + @n_size[@chosen_size][0]
			@@size_index = @chosen_size 
		if @chosen_size >= 12 
			prompts = "Width", "Depth"
			values = [@@custom_size[1],@@custom_size[2 ]]
				results = inputbox prompts,	values, "Enter Custom Size (actual)"
			if results 
				width, depth = results
				s_label = "Custom " + width.to_s + ' x ' + depth.to_s
				@n_size[12] = [s_label,width.to_l ,depth.to_l ]
			end 
		end
		@@nom_size[0] = @n_size[@chosen_size][1].to_l  
	  @@nom_size[1] = @n_size[@chosen_size][2].to_l
		@@custom_size = @n_size[12]
		if @@length_unit <=1 
        @@act_size = [0.0.to_l,0.0.to_l]
      if @chosen_size < 12 
        @@act_size.each_index {|i| 
            if @@nom_size[i]  > 1.0.inch 
              @@act_size[i] = @@nom_size[i] - 0.25.inch
            else 
              @@act_size[i] = @@nom_size[i] - 0.125.inch
            end
        }
      else
        @@act_size[0]=@@custom_size[1]
        @@act_size[1] = @@custom_size[2]
      end
			w = @@act_size[0] 
			d = @@act_size[1]
		else 
			@@act_size = [0.0.to_l,0.0.to_l] 
			if @chosen_size < 12 
        @@act_size.each_index {|i| 
          if @@nom_size[i] > 25.mm 
            @@act_size[i] = @@nom_size[i] - 6.mm
          else 
            if @chosen_size < 12
              @@act_size[i] = @@nom_size[i] - 3.mm
            end
          end
        }
      else
        @@act_size[0]=@@custom_size[1]
        @@act_size[1] = @@custom_size[2]
      end
			w = @@act_size[0] 
			d = @@act_size[1]
		end
		@ip	 = Sketchup::InputPoint.new
		@ip1	= Sketchup::InputPoint.new
		@ip2	= Sketchup::InputPoint.new
		@drawn	= false
		@last_drawn = nil
		@stipple	= ["_",	".",	"-", "-.-"]
		Sketchup::set_status_text("Length", SB_VCB_LABEL)
		if Sketchup.active_model.rendering_options["HideConstructionGeometry"] == true 
			Sketchup.active_model.rendering_options["HideConstructionGeometry"] = false 
		end
		self.reset(nil)
	end
def activate if @@suspended self . resume ( nil ) end @n_size [ 12 ] = @@custom_size if ! @chosen_size @chosen_size = @@size_index end s_label = @n_size [ @chosen_size ] @cursor_text = "\n\n" + @n_size [ @chosen_size ] [ 0 ] @@size_index = @chosen_size if @chosen_size >= 12 prompts = "Width" , "Depth" values = [ @@custom_size [ 1 ] , @@custom_size [ 2 ] ] results = inputbox prompts , values , "Enter Custom Size (actual)" if results width , depth = results s_label = "Custom " + width . to_s + ' x ' + depth . to_s @n_size [ 12 ] = [ s_label , width . to_l , depth . to_l ] end end @@nom_size [ 0 ] = @n_size [ @chosen_size ] [ 1 ] . to_l @@nom_size [ 1 ] = @n_size [ @chosen_size ] [ 2 ] . to_l @@custom_size = @n_size [ 12 ] if @@length_unit <= 1 @@act_size = [ 0.0 . to_l , 0.0 . to_l ] if @chosen_size < 12 @@act_size . each_index { | i | if @@nom_size [ i ] > 1.0 . inch @@act_size [ i ] = @@nom_size [ i ] - 0.25 . inch else @@act_size [ i ] = @@nom_size [ i ] - 0.125 . inch end } else @@act_size [ 0 ] = @@custom_size [ 1 ] @@act_size [ 1 ] = @@custom_size [ 2 ] end w = @@act_size [ 0 ] d = @@act_size [ 1 ] else @@act_size = [ 0.0 . to_l , 0.0 . to_l ] if @chosen_size < 12 @@act_size . each_index { | i | if @@nom_size [ i ] > 25 . mm @@act_size [ i ] = @@nom_size [ i ] - 6 . mm else if @chosen_size < 12 @@act_size [ i ] = @@nom_size [ i ] - 3 . mm end end } else @@act_size [ 0 ] = @@custom_size [ 1 ] @@act_size [ 1 ] = @@custom_size [ 2 ] end w = @@act_size [ 0 ] d = @@act_size [ 1 ] end @ip = Sketchup :: InputPoint . new @ip1 = Sketchup :: InputPoint . new @ip2 = Sketchup :: InputPoint . new @drawn = false @last_drawn = nil @stipple = [ "_" , "." , "-" , "-.-" ] Sketchup :: set_status_text ( "Length" , SB_VCB_LABEL ) if Sketchup . active_model . rendering_options [ "HideConstructionGeometry" ] == true Sketchup . active_model . rendering_options [ "HideConstructionGeometry" ] = false end self . reset ( nil ) end
The activate method is called by SketchUp when the tool is first selected, or when R-click menu is called
it is a good place to put most of your initialization
The activate method is called by SketchUp when the tool is first selected or when R - click menu is called it is a good place to put most of your initialization
# Resume if previously suspended # set custom size to default or that used last # Set default timber size to 2" x 1" or 50 x 25mm (@chosen_size index = 1) if no size is set # Size index was initialized to 1, or gets set later to be remembered here ## Set chosen size to display below cursor # Update remembered timber size			 ## Build context menu array to display on R-click, to select timber size # Then pop up a menu to set Custom Size(s) #not nil # @c_menu[11] = [@n_size[11][0],11]			 ## Remember size(s) last chosen ## Set actual size in imperial or metric units according to model unit settings # imperial sizes in use ## Convert from nominal to actual size - take 1/4" off nominal if 1" or over, 1/8" off otherwise   # for standard sizes only  # Check width and depth dimensions to see how much to reduce nominal size # puts "Nominal size for dim = " + i.to_s + " = " + @@nom_size[i].to_s  # use actual (not nominal) dimensions for custom size # Metric units in use ## Convert from nominal to actual size - take 6mm off nominal if 25mm or over, 3mm off otherwise   #Initialise variable as lengths # for standard sizes only # Check width and depth dimensions to see how much to reduce nominal size # puts "Nominal size for dim = " + i.to_s + " = " + @@nom_size[i].to_s  # puts "Nominal size for dim = " + i.to_s + " = " + @@nom_size[i].to_s  # use actual custom size (not nominal) #puts "Nominal size = " + @@nom_size.inspect + "\n" #puts "Actual size = " + @@act_size.inspect + "\n"				 # The Sketchup::InputPoint class is used to get 3D points from screen # positions.	It uses the SketchUp inferencing code. # In this tool, we will have two points for the endpoints of the line. # Unhide Construction Geometry (hangover from original Construction Line Tool)