In a customized move tool, I would like to hide the moved component instance until the user click on the destination point to be able to draw only its skeleton.
I tried the following trick :
instance.move!(Geom::scaling(0.0))
It seems to work as expected on current SketchUp versions, but it uses a null matrix that may be a problem for the future.
Did someone find a better way to temporarily hide a component instance ?
one idea:
You can start_operation on the first click and hide the instance.
Then on a second click abort_operation then make start_operation again followed by transforming the instance into place. than commit_operation. In a meantime put abort_operation within onCancel(reason, view) method so if the user hit Escape or other reason, the hidden will be revoked.
Something like this (it is just a concept, did not tried…)
class ExampleTool
def initialize
@stage = 0
end
def onCancel(reason, view)
view.model.abort_operation
@stage = 0
view.invalidate
end
def onLButtonDown(flags, x, y, view)
if @stage == 0
view.model.start_operation("hide")
@instance.hidden = true
@stage += 1
else
view.model.abort_operation #this will unhide the instance
view.model.start_operation("move")
#transform instance to place
view.model.commit_operation
end
view.invalidate
end
def onMouseMove(flags, x, y, view)
#calculatet the trnsformation...etc
end
def draw(view)
# draw the bounds of instance if stage not 0
end
end
By the way, you can move the instance constantly - by set transformation in onMouseMove -using a similar method and you don’t have to hide it and don’t need to draw temporarily bounds…
BTW. I wery much like your trick with instance.move!(Geom::scaling(0.0)) !!!
Of course, it would be nice if we could apply it to just one instance in Ruby, like the Move Tool is doing it… (Changing the material and back of each face would be too intensive task for pure Ruby, I think.)