src/jwm_draw_framing/draw_framing_main.rb
#----------------------------
# onUserText is called when the user enters something into the VCB
# In this implementation, we create a line of the entered length if
# the user types a length while selecting the second point
onUserText is called when the user enters something into the VCB
In this implementation, we create a line of the entered length if
the user types a length while selecting the second point
onUserText is called when the user enters something into the VCB In this implementation we create a line of the entered length if the user types a length while selecting the second point
def onUserText(text, view)
		begin
		value = text.to_l
		rescue
		UI.beep
		UI.messagebox "Cannot convert #{text} to a Length"
		value = nil
		Sketchup::set_status_text "", SB_VCB_VALUE
		end
		return if !value
		if @state == 1 and @ip2.valid?
		pt1 = @ip1.position
		vec = @ip2.position - pt1
		if( vec.length == 0.0 )
			UI.beep
			return
		end
		vec.length = value
		pt2 = pt1 + vec
		self.create_geometry(pt1, pt2, view)
		self.reset(view)
		end
		if @last_drawn and @state == 0
		pt1 = @last_drawn[0].start
		vec = @last_drawn[0].end - @last_drawn[0].start
		vec.length = value
		pt2 = pt1 + vec
		view.model.active_entities.erase_entities @last_drawn
		self.create_geometry(pt1, pt2, view)
		self.reset view
		end
	end
def onUserText ( text , view ) begin value = text . to_l rescue UI . beep UI . messagebox "Cannot convert #{text} to a Length" value = nil Sketchup :: set_status_text "" , SB_VCB_VALUE end return if ! value if @state == 1 and @ip2 . valid? pt1 = @ip1 . position vec = @ip2 . position - pt1 if ( vec . length == 0.0 ) UI . beep return end vec . length = value pt2 = pt1 + vec self . create_geometry ( pt1 , pt2 , view ) self . reset ( view ) end if @last_drawn and @state == 0 pt1 = @last_drawn [ 0 ] . start vec = @last_drawn [ 0 ] . end - @last_drawn [ 0 ] . start vec . length = value pt2 = pt1 + vec view . model . active_entities . erase_entities @last_drawn self . create_geometry ( pt1 , pt2 , view ) self . reset view end end
onUserText is called when the user enters something into the VCB
In this implementation, we create a line of the entered length if
the user types a length while selecting the second point
onUserText is called when the user enters something into the VCB In this implementation we create a line of the entered length if the user types a length while selecting the second point
# We only accept input when the state is 1 (i.e. getting the second point) # This could be enhanced to also modify the last line created if a length # is entered after creating a line. #return if not @state == 1 #return if not @ip2.valid? #p @ip2.valid? # The user may type in something that we can't parse as a length # so we set up some exception handling to trap that # Error parsing the text # Compute the direction and the second point # Create a line #@last_drawn = nil
text
<not_specific>
view
<not_specific>