I have created a tool that places components. Upon deactivation I call a method outside my tool that starts the process over(it opens a dialog to select a component to place).However on the second time around it skips over all my methods and jumps to starting the process all over again.
def initialize(component, rotateComponent, isSelect)
@ip = Sketchup::InputPoint.new
@componentDefinition = component
@comp = nil
@isRotate = rotateComponent
@rotation = 0
@rotateTransformation = nil
@openSelect = isSelect
end#def initialize
def deactivate(view)
view.invalidate
self.clearComponent view
end#def deactivate
def clearComponent(view)
model = view.model
entities = model.active_entities
if(@comp != nil)
entities.erase_entities @comp
end#if
if(@openSelect == 1)
@openSelect = nil
MyModule::reopenSelection(1)
else
@openSelect = nil
MyModule::reopenSelection(0)
end#if
model.abort_operation
end#def clearComponent
To be more specific. The user opens a dialog window and selects which component they want to place in the scene. Once they select one, I create a tool to place:
myTool = MyModule::PlaceTool.new(newComponent, rotateComponent, isSelect)
Sketchup.active_model.select_tool(myTool)
Inside that tool upon deactivate I call clearComponent to stop the placing and then call to open the dialog window again. reopenSelection checks which dialog to open(1 or 0), then calls the initial method that started the entire process.