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

    Get mouse x,y,z location other an with an Inputpoint?

    Scheduled Pinned Locked Moved Developers' Forum
    20 Posts 6 Posters 1.2k Views 6 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      I have not looked too much into this yet, but is there a way to get the 3d position of the cursor other than using an inputpoint? I was wondering if casting a ray would work. Does that return a point3d object? If I go that route, do I need to sort through what objects are or are not hidden/visible? Also, if it matters, I am only concerned about 3d points on a face. So if the mouse is hovering over nothing, I do not need to determine a 3d point for that. Just returning "nil" in that scenario is fine.

      So what do you think, is there a non-inputpoint method for this?

      Chris

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

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

        Why do you not want to use an InputPoint? You can use the ip.face to test if you got the point from a face and ignore the rest.

        But, yes, you can shoot a ray:

        ` ray = view.pickray(x, y)
        result = model.ray_test( ray )

        TODO: Recast on hidden entities`

        Then remember that in SU8 the ray_test is FUBAR.

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

        1 Reply Last reply Reply Quote 0
        • KrisidiousK Offline
          Krisidious
          last edited by

          does the "Tools > utilities > querry tool" not do that?

          By: Kristoff Rand
          Home DesignerUnique House Plans

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            @Kris - yes, the query tool returns the 3d position of the cursor. But it tends to jump to the edges and vertices. I'm trying to avoid that.

            I'll play with ray casting. I'll have to read over your ray casting thread and the workaround to see if I can get it to work at all.

            The reason I do not want to use an IP point, is because my plugin needs to only find points on a face. BUT points on a face get low priority "snapping". Meaning if I hover over a face, and I get near a vertex, the cursor jumps to the vertex. I'd really like to be less sensitive to the vertices and edges. I guess I finally found a legitimate reason to want to cancel out some of the inferencing, but leave "onface" inferecing on.

            Currently I am just ignoring the IP if it is not on a face. But that means that there are times when the user clicks and nothing happens. So it is just a little weird. But I can get over it if it is the best way to get a point3d object.

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

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

              @chris fullmer said:

              I'll play with ray casting. I'll have to read over your ray casting thread and the workaround to see if I can get it to work at all.

              Don't bother with the workaround - it's broken. Test in SU7 and wait for SU8 to be updated.

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

              1 Reply Last reply Reply Quote 0
              • KrisidiousK Offline
                Krisidious
                last edited by

                Chris...

                try holding ALT while you point it around... the querry tool. see if that stops it from jumping.

                By: Kristoff Rand
                Home DesignerUnique House Plans

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

                  @chris fullmer said:

                  Currently I am just ignoring the IP if it is not on a face. But that means that there are times when the user clicks and nothing happens. So it is just a little weird. But I can get over it if it is the best way to get a point3d object.

                  PickHelper.picked_face would be what you want then - and then the pickray to get the 3d co-ordinate.

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

                  1 Reply Last reply Reply Quote 0
                  • Chris FullmerC Offline
                    Chris Fullmer
                    last edited by

                    @Kris - hmm, holding alt seems to do nothing on my computer in the query tool. Does it change the behavior for you I'm guessing?

                    Lately you've been tan, suspicious for the winter.
                    All my Plugins I've written

                    1 Reply Last reply Reply Quote 0
                    • KrisidiousK Offline
                      Krisidious
                      last edited by

                      well if you click alt while you're mousing around it will stick a little purple vertex mark in place where you were and the xyz location will hold.

                      By: Kristoff Rand
                      Home DesignerUnique House Plans

                      1 Reply Last reply Reply Quote 0
                      • Chris FullmerC Offline
                        Chris Fullmer
                        last edited by

                        What it looks like is happening to me is that when you hit alt, it is going into the menu system - "File" is highlighted. Once the menu system is activated, the dot stays in place until alt is pressed again getting out of the menu system. I also see this behavior with the native tools like the line tool. At least that is what I'm seeing.

                        Lately you've been tan, suspicious for the winter.
                        All my Plugins I've written

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

                          Yea - Alt is Window' global hotkey to activate the menubar of the active window.

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

                          1 Reply Last reply Reply Quote 0
                          • KrisidiousK Offline
                            Krisidious
                            last edited by

                            yes it is... but it also has the move on to extra plane and allow new faces to be created function. when I hit alt while querrying it hold the purple marker where ever I leave it and stays at a specific two coords. since one coord is already known I took it.

                            alt-action-querry1.jpg

                            alt-action-querry2.jpg

                            By: Kristoff Rand
                            Home DesignerUnique House Plans

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

                              @krisidious said:

                              yes it is... but it also has the move on to extra plane and allow new faces to be created function. when I hit alt while querrying it hold the purple marker where ever I leave it and stays at a specific two coords. since one coord is already known I took it.

                              That is not a design by the tool - it's a side-effect from Windows sending the focus to the menubar. Don't think it behaves like this on OSX.

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

                              1 Reply Last reply Reply Quote 0
                              • Chris FullmerC Offline
                                Chris Fullmer
                                last edited by

                                It is a cool side effect, but it is not quite what I am looking for though anyhow. Because the query tool is still snapping to edges more than I wish it was. I'll just implement the InputPoint 3d position method, and wait until they hopefully fix the pickray for version8. Thank guys,

                                Chris

                                Lately you've been tan, suspicious for the winter.
                                All my Plugins I've written

                                1 Reply Last reply Reply Quote 0
                                • W Offline
                                  Whaat
                                  last edited by

                                  @thomthom said:

                                  But, yes, you can shoot a ray:

                                  ` ray = view.pickray(x, y)
                                  result = model.ray_test( ray )

                                  TODO: Recast on hidden entities`

                                  I have been using this method quite successfully but it does not work well if there is an 'out-of-context' face between the camera and the user's mouse position. This is even more of a problem if the user has 'Component Edit->Hide Rest of Model' The new raytest flag in SU8 that is supposed to ignore hidden geometry is not effective in this case. IMO it should also work for this situation.

                                  SketchUp Plugins for Professionals

                                  1 Reply Last reply Reply Quote 0
                                  • Chris FullmerC Offline
                                    Chris Fullmer
                                    last edited by

                                    Could you test if the hit entity is in the current context, and just ignore it if it is not? That seems like it might be a solid workaround? Though I suppose that might be overkill because in many cases the user will not have 'Hide Rest of Model' turned on. So in those cases, you might want the user to be able to pick points outside the current context....hhmmmm.

                                    Lately you've been tan, suspicious for the winter.
                                    All my Plugins I've written

                                    1 Reply Last reply Reply Quote 0
                                    • fredo6F Offline
                                      fredo6
                                      last edited by

                                      @chris fullmer said:

                                      I have not looked too much into this yet, but is there a way to get the 3d position of the cursor other than using an inputpoint? I was wondering if casting a ray would work. Does that return a point3d object? If I go that route, do I need to sort through what objects are or are not hidden/visible? Also, if it matters, I am only concerned about 3d points on a face. So if the mouse is hovering over nothing, I do not need to determine a 3d point for that. Just returning "nil" in that scenario is fine.

                                      Chris,

                                      I typically use a combination of InputPoint, to get the (x, y) in 2D and the face, and then view.Pickrayto intersect with the face and find the 3D point.

                                      This is more or less what I have used in FreeHand On Surface, in particular to get rid of the inferences.

                                      Fredo

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

                                        @chris fullmer said:

                                        ... Though I suppose that might be overkill because in many cases the user will not have 'Hide Rest of Model' turned on.

                                        You can test that thru the RenderingOptions hash's InactiveHidden and InstanceHidden attributes.

                                        <span class="syntaxdefault">if Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">rendering_options</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'InactiveHidden'</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment"># do it this way<br /></span><span class="syntaxkeyword">else<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment"># do it that way<br /></span><span class="syntaxdefault">end</span>
                                        

                                        I'm not here much anymore.

                                        1 Reply Last reply Reply Quote 0
                                        • Chris FullmerC Offline
                                          Chris Fullmer
                                          last edited by

                                          Well there you have it! Glad you can test if they have Hide Rest of Model on or off. I had my doubts about truly being able to come up with a flawless solution to get 3dpoints from the cursor while ignoring inferencing, but this thread seems to indicate that its possible. I'll have to re-write my app I was making while I started this thread, because it currently just ignores the mouseclick anytime it gets inferred onto an edge. Very good, my little plugin might finally be useful 😄

                                          Chris

                                          Lately you've been tan, suspicious for the winter.
                                          All my Plugins I've written

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

                                            @chris fullmer said:

                                            Well there you have it! Glad you can test if they have Hide Rest of Model on or off.

                                            Just be aware that Scene (Pages) can also have their own RendingOptions hash instance.

                                            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