src/jwm_draw_framing/draw_framing_main_v0.56.rb
#---------------------------------------------
# Create new geometry when the user has selected two points.
Create new geometry when the user has selected two points.
Create new geometry when the user has selected two points .
def create_geometry(p1, p2, view)
		if @state < 2 
			@model = Sketchup.active_model
			@model.tools.add_observer(MyToolsObserver.new)
			@model.start_operation("DrawFraming")
			@@df_tool_id = @model.tools.active_tool_id 
			@grp = @model.active_entities.add_group()
			@ents = @grp.entities
			@face = @ents.add_face(@pts0)
			comp_name = UI.inputbox ["Component name"],["Frame element"],"Name this component instance" 
			if comp_name 
				@grp.description= comp_name[0].to_s 
				@comp = @grp.to_component
				@comp.definition().name = @n_size[@chosen_size][0] + " "  + comp_name[0].to_s
				@comp.transform!(@tf2 )
				@last_drawn = [@comp]
				@model.selection.clear
				@model.selection.add @face
				@face.reverse!
				@state = 2 
				@model.commit_operation
			else
				 @ents.clear!
				view.refresh  
				self.reset(view)
				@state = 0
			end 
				self.suspend(view) 
		end 
	end
def create_geometry ( p1 , p2 , view ) if @state < 2 @model = Sketchup . active_model @model . tools . add_observer ( MyToolsObserver . new ) @model . start_operation ( "DrawFraming" ) @@df_tool_id = @model . tools . active_tool_id @grp = @model . active_entities . add_group ( ) @ents = @grp . entities @face = @ents . add_face ( @pts0 ) comp_name = UI . inputbox [ "Component name" ] , [ "Frame element" ] , "Name this component instance" if comp_name @grp . description = comp_name [ 0 ] . to_s @comp = @grp . to_component @comp . definition ( ) . name = @n_size [ @chosen_size ] [ 0 ] + " " + comp_name [ 0 ] . to_s @comp . transform! ( @tf2 ) @last_drawn = [ @comp ] @model . selection . clear @model . selection . add @face @face . reverse! @state = 2 @model . commit_operation else @ents . clear! view . refresh self . reset ( view ) @state = 0 end self . suspend ( view ) end end
Create new geometry when the user has selected two points.
Create new geometry when the user has selected two points .
#then we haven't yet created any geometry, so create the cross-section face # Watch for tool change - when PushPull tool called suspend DrawFraming, and resume when  # PushPull tool finished # Remember DrawFraming tool_id # Create an empty group to draw into # Draw cross-section at origin (so the component axes will be at the corner of the face), # name it, and make it into a component # isn't nil (naming inputbox not cancelled) # Move face from origin to pick point # Waiting for pick or VCB entry to define length of component # Clean up drawn face and edges, and reset view #@model.abort_operation # alternative way to cancel # if comp_name # Pushpull cross-section to length # Suspend this tool, and select PushPullTool instead in suspend method  # if
p1
<not_specific>
p2
<not_specific>
view
<not_specific>