Detect if cpoint is clicked
-
Hi,
I'm reading API and it seems that InputPoint class can't detect if cpoint is clicked? It there some other method to detect it?
Description of my problem
I'm calculating some values for numerous sensors in the model. When importing data back into model, plugin create cpoint for each sensor, and idea is when user click on cpoint to show its value (in tooltip, if possible, or in some other report dialog, if not possible).My current implementation creates cpoints and also add text into model (containing value for the point). Problem is that such text entities (one for each sensors, and there can be 10000 sensors or so), make model overcrowded and difficult to explore.
New idea is to add only cpoints into model, and then show values to user 'on demand' - click or mouse move.
Back to the problem, I can detect current mouse position, but how to check if it is on cpoint or not?
Any ideas? Is there some plugin that does similar import of numerical values, since I'm searching for some solution comfortable for user and efficient!
Thanks in advance,
Marija -
Have you tried the PickHelper class?
-
Hi,
I've managed to make it work, with help of Thom Thom's Pick It tool and PickHelper and this thread http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=48919%26amp;p=439766%26amp;hilit=tooltip#p439766
Idea is to detect leaf with PickHelper, and if it is cpoint then print whatever needed
def onMouseMove(flags, x, y, view) ph = view.pick_helper ph.do_pick(x, y) ph.count.times { |index| ent = ph.leaf_at(index) if ent.class == Sketchup;;ConstructionPoint view.tooltip = ent.to_s break end } view.refresh end
Thanks Thom,
Marija -
Why do you need to call
view.pick_helper
each time the mouse moves ?Can't you use
@ph = view.pick_helper
in the tool'sactivate
callback ?
And then re-use the pick_helper instance reference ? -
Hi Dan,
Good point for defining pick helper only once, and then use it. I was concerned what would happen if user select other Scene for example while tool is active, but it seems it is working fine.
def activate view = Sketchup.active_model.active_view @ph = view.pick_helper end def onMouseMove(flags, x, y, view) @ph.do_pick(x, y) @ph.count.times { |index| ent = @ph.leaf_at(index) if ent.class == Sketchup;;ConstructionPoint view.tooltip = ent.to_s break end } view.refresh end
Thanks again,
Marija -
@maricanis said:
I was concerned what would happen if user select other Scene for example while tool is active, ...
I believe the
active_view
is a singleton object of the model. (there is only one.) The user sees scene pages through theactive_view
.
Advertisement