sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Detect if cpoint is clicked

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 414 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      maricanis
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Have you tried the PickHelper class?

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • M Offline
          maricanis
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            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's activate callback ?
            And then re-use the pick_helper instance reference ?

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • M Offline
              maricanis
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @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 the active_view.

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement