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

    Model.raytest and Entity visibillity

    Scheduled Pinned Locked Moved Developers' Forum
    28 Posts 6 Posters 1.8k 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.
    • thomthomT Offline
      thomthom
      last edited by

      @Alex: your each_element_satisfies?(&block) does the same as the native Enumerable.all?

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

      1 Reply Last reply Reply Quote 0
      • K Offline
        kwalkerman
        last edited by

        I've been using model.raytest on SU 7.1 pro. It has not seen hidden entities (which I like!)

        Sounds like in SU 8, things are all messed up. Maybe a new raytest method could be developed where you can specify whether the ray is allowed to return something hidden or not?

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

          @kwalkerman said:

          I've been using model.raytest on SU 7.1 pro. It has not seen hidden entities (which I like!)

          Sounds like in SU 8, things are all messed up. Maybe a new raytest method could be developed where you can specify whether the ray is allowed to return something hidden or not?

          In SU7 and older model.raytest stopped on hidden layers, but not on hidden entities.
          In SU8 it stops on hidden layers and entities, but there is a bug where some rays fail.

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

          1 Reply Last reply Reply Quote 0
          • K Offline
            kwalkerman
            last edited by

            Weird. Are they homing in on anything consistent?

            --
            Karen

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

              @kwalkerman said:

              Weird. Are they homing in on anything consistent?

              Seems that they made it stop on any entity regardless of visibility - which mean we need to check that our selves and recast the ray.
              But also managed to introduce a new nasty bug. 😕

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

              1 Reply Last reply Reply Quote 0
              • T Offline
                tomasz
                last edited by

                @thomthom said:

                Seems that they made it stop on any entity regardless of visibility - which mean we need to check that our selves and recast the ray.

                EDIT: In my experience it was always the case.

                @thomthom said:

                But also managed to introduce a new nasty bug. 😕

                😕 😡

                Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

                1 Reply Last reply Reply Quote 0
                • Al HartA Offline
                  Al Hart
                  last edited by

                  OOf...

                  Glad to find this thread. Several of our placement tools have started failing in SU 8.

                  We were using raytest to try to find a specific object behind the cursor, and then hiding anything we did not want to locate.

                  In this example, we are placing a component, and want raytest to ignore the component we are placing (We make it visible so the user can see it). This is from our "spray paint" tool which is trying to place trees randomly on the ground, but not on other trees which we just placed.

                  
                              item = model.raytest ray
                  
                              #Ignore any elements of the same type we are placing
                              hidden_ents = Array.new
                              while(item != nil && item[1].at(0).kind_of?(Sketchup;;ComponentInstance) && item[1].at(0).definition == definition)
                                  hidden_ents.push(item[1][0])
                                  item[1][0].hidden = true
                                  item = model.raytest ray
                              end
                              hidden_ents.each {
                                  |ent|
                                  ent.hidden = false
                              }
                  

                  However, in SU 8, hiding the component instance, when it is under the cursor - does not leave it out of the ray test. (We also discovered a nasty bug where we were looping forever if we are over the component being placed)

                  Can anyone think of a way to place components at the end of a ray, but ignore certain elements. Apparently .hidden will not work, and not even placing them on a temporary hidden layer. I haven't tried deleting them, (and then aborting the delete operation), yet. But it seems pretty painful.

                  Al Hart

                  http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                  IRender nXt from Render Plus

                  1 Reply Last reply Reply Quote 0
                  • Al HartA Offline
                    Al Hart
                    last edited by

                    @unknownuser said:

                    @thomthom said:

                    Seems that they made it stop on any entity regardless of visibility - which mean we need to check that our selves and recast the ray.

                    EDIT: In my experience it was always the case.

                    @thomthom said:

                    But also managed to introduce a new nasty bug. 😕

                    😕 😡

                    In reference to my previous post. Can I just move the ray itself past the point returned and "recast" it. Still, while trying to ignore an entire tree, or other component, this could be painful.

                    Al Hart

                    http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                    IRender nXt from Render Plus

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

                      @al hart said:

                      In reference to my previous post. Can I just move the ray itself past the point returned and "recast" it. Still, while trying to ignore an entire tree, or other component, this could be painful.

                      It's what I do in my wrapper method that ensures the ray doesn't stop on hidden entities.

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

                      1 Reply Last reply Reply Quote 0
                      • Al HartA Offline
                        Al Hart
                        last edited by

                        @thomthom said:

                        @al hart said:

                        It's what I do in my wrapper method that ensures the ray doesn't stop on hidden entities.

                        [EDIT: I see some code in a previous post. I will try it out]

                        Thanks,

                        Is there some code here in this thread already, or can you show me what you are doing to skip hidden geometry?

                        Al Hart

                        http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                        IRender nXt from Render Plus

                        1 Reply Last reply Reply Quote 0
                        • Al HartA Offline
                          Al Hart
                          last edited by

                          Thanks tons, ThomThom, by tool is working again! ☀

                          Al Hart

                          http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                          IRender nXt from Render Plus

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

                            @al hart said:

                            @thomthom said:

                            @al hart said:

                            It's what I do in my wrapper method that ensures the ray doesn't stop on hidden entities.

                            [EDIT: I see some code in a previous post. I will try it out]

                            Thanks,

                            Is there some code here in this thread already, or can you show me what you are doing to skip hidden geometry?

                            Bottom of first post:
                            http://forums.sketchucation.com/viewtopic.php?f=180&t=28059#p243311

                            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

                              I've used a little recursive method to check what I am hitting. If I do not like what I hit, I recall the method supply the Point3d of the last thing I hit. It remakes the ray and casts it again until I hit what I'm after.

                              It has worked perfectly so far. But I'm concerned about the rays that don't work if they are shot through the groundplane? Is that still an issue in 8?

                              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:

                                It has worked perfectly so far. But I'm concerned about the rays that don't work if they are shot through the groundplane? Is that still an issue in 8?

                                "Still an issue in 8"? Has it been an issue before?
                                At it turned out - it's not only when the ray passes through the axis planes - but also at random times. model.raytest is fubar in SU8 - not reliable.

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

                                1 Reply Last reply Reply Quote 0
                                • K Offline
                                  kwalkerman
                                  last edited by

                                  Ok, so here's an issue with the new way raytest works (ie it sees all entities, visible and hidden).

                                  There are times when a ray will hit multiple entities at the same point. In SU 7, model.raytest will return only one of those entities. It's easy to find all entities by hiding any entities that are hidden, but under the new version of SU, only one of the entities will be found. Another thing, which is interesting, is that if there are multiple entities in the same location, SU will return the same entity first, regardless of the direction of the ray.

                                  Try this code:

                                  
                                  model = Sketchup.active_model
                                  p1 = Geom;;Point3d.new(0,0,0)
                                  p2 = Geom;;Point3d.new(20,20,0)
                                  p3 = Geom;;Point3d.new(0,20,0)
                                  f = model.entities.add_face(p1,p2,p3)
                                  model.entities.add_group([f])
                                  model.entities.add_face(p1,p2,p3)
                                  p4 = Geom;;Point3d.new(5,10,-5)
                                  p5 = Geom;;Point3d.new(5,10,5)
                                  ray1 = [p4, Geom;;Vector3d.new(0,0,1)]
                                  item1 = model.raytest ray1
                                  ray2 = [p5, Geom;;Vector3d.new(0,0,-1)]
                                  item2 = model.raytest ray2
                                  item1 == item2
                                  
                                  #==> returns TRUE!
                                  
                                  

                                  I can't currently think of a ruby workaround for this. The new version of raytest will limit the ability to get all objects at a certain location.

                                  As I suggested before, I think it makes the most sense to extend the native raytest so that you can specify whether or not you want the ray to be allowed to show hidden objects.

                                  --
                                  Karen

                                  1 Reply Last reply Reply Quote 0
                                  • Al HartA Offline
                                    Al Hart
                                    last edited by

                                    @kwalkerman said:

                                    I can't currently think of a ruby workaround for this. The new version of raytest will limit the ability to get all objects at a certain location.

                                    --
                                    Karen

                                    It would be fairly painful, but you could start an undo operation, delete each item as it is found (rather than changing the starting point of the ray, ot just hiding the object) and continue until all objects are found (saving their object IDs), then abort the operation to restore everything to the database.

                                    Al Hart

                                    http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                                    IRender nXt from Render Plus

                                    1 Reply Last reply Reply Quote 0
                                    • T Offline
                                      tomasz
                                      last edited by

                                      @kwalkerman said:

                                      As I suggested before, I think it makes the most sense to extend the native raytest so that you can specify whether or not you want the ray to be allowed to show hidden objects.

                                      I have proposed it TWO years ago.... G Team isn't responsive.

                                      Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

                                        Hmm, nevermind. I retract this post, I was confused 😄

                                        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

                                          Right, so the raytest should have an argument to ignore hidden.

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

                                          1 Reply Last reply Reply Quote 0
                                          • Al HartA Offline
                                            Al Hart
                                            last edited by

                                            @thomthom said:

                                            Right, so the raytest should have an argument to ignore hidden.

                                            And, hopefully, they will make it an optional argument, so they don't break all the existing ruby files once again.

                                            Al Hart

                                            http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                                            IRender nXt from Render Plus

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

                                            Advertisement