• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Selecting All Visible Faces

Scheduled Pinned Locked Moved Developers' Forum
17 Posts 5 Posters 5.5k Views
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.
  • G Offline
    gude
    last edited by 26 Oct 2010, 13:22

    Hello.
    I'm a noob to coding, I'm just reading Automatic sketchup to learn ruby.
    I wanted a way select all visible faces without the back faces etc. (as in max?) or at least those visible from an orthographic camera view but i cant figure out how?
    Thank you !

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 26 Oct 2010, 13:34

      @gude said:

      I wanted a way select all visible faces without the back faces etc. (as in max?)

      You mean the Ignore Backfaces feature - it simply ignores faces which normal is facing away from the camera, but it does not take into account if a face is occluded by another entity. But that is quick and easy to do though - did that in Vertex Tools.

      Determining if an entity is actually visible or not is more tricky and more time consuming. (And what do you do with partially visible entities?)

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

      1 Reply Last reply Reply Quote 0
      • G Offline
        gude
        last edited by 26 Oct 2010, 13:51

        Thanks a lot thom for quick reply.
        Exactly the ignore back faces...
        My Initial focus was to select visible faces and project them to plane for an elevation.
        So as these partial faces appear in elevations Its ideal to include them in selection. And if possible otherwise is to create an additional cut-out geometry from the visible excluding the hidden ones.
        Thanks once again.

        1 Reply Last reply Reply Quote 0
        • H Offline
          honoluludesktop
          last edited by 26 Oct 2010, 17:06

          Tom, Is there a existing plugin that selects all visible faces including partial visible ones? If so do you have a link?

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 26 Oct 2010, 17:49

            I'm not aware of any..

            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 28 Oct 2010, 14:21

              I'm not sure what your end goal is here, but with SU pro, you can export as a 2D drawing into all kinds of formats, DWG included, which will show you only the current view.

              It would be nice if the camera object had an "all_visible" function... but as far as I know, it doesn't. The only way I know to find objects that are visible, is to do model.raytest, which is time consuming, and only tests one ray at a time.

              --
              Karen

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 28 Oct 2010, 14:25

                And another problem with raytest is what points to test? testing just vertices isn't enough, they could all be hidden from the camera, but a part of the surface might be visible.

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

                1 Reply Last reply Reply Quote 0
                • C Offline
                  Chris Fullmer
                  last edited by 28 Oct 2010, 18:06

                  I just wrote a test code that run pickhelper on every x,y of the screen and adds everything it hits to the selection.

                  It worked ok. Biggest problems are that it can miss tiny faces (though it was a LOT better than I thought it would be) and even worse - it was over-zealous. It added things that were definitely not visible.

                  But I'd say it was about 80% good. You can play with it here:

                  WARNING: This is EXTREMELY slow. Minimize your window to a large thumbnail size view if you just want to quickly test this. Full size window takes easily over an hour to process I think.

                  view = Sketchup.active_model.active_view
                  Sketchup.active_model.selection.clear
                  w = view.vpwidth
                  h = view.vpheight
                  w.times do |x|
                    h.times do |y|
                      ph = view.pick_helper
                      ph.do_pick x,y
                      t = ph.all_picked
                      t.each do |ent|
                        if (ent.is_a? Sketchup;;Face) or (ent.is_a? Sketchup;;Edge)
                          Sketchup.active_model.selection.add ent
                        end
                      end
                    end
                  end
                  

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

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 28 Oct 2010, 18:07

                    The pick_helper has an aperture, have you tried adjusting that and see if you get different results?

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

                    1 Reply Last reply Reply Quote 0
                    • C Offline
                      Chris Fullmer
                      last edited by 28 Oct 2010, 18:15

                      No, I did not play with it at all....might be intersting.

                      I think the reason it over actively picks things is at least 2 fold. 1 - I am adding all picked ents (as opposed to best_picked, which I think you hit an edge of a face that is not visible, it returns the face anyhow. 2 - it seems to pick right through close faces. So if a hidden face is clse to the front face, I think it wll pick right through the front face, much like z-fighting.

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

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        honoluludesktop
                        last edited by 28 Oct 2010, 18:58

                        Hi Chris, That's a neat snippet.

                        1 Reply Last reply Reply Quote 0
                        • C Offline
                          Chris Fullmer
                          last edited by 29 Oct 2010, 01:18

                          Thanks, it would be a lot cooler if it was fast and accurate πŸ˜„ I would like to play with the aperture size. Maybe that would help speed things up? What if the aperture could be sut to the height and width of the monitor, and then just run a single "pick" and choose all selected. I'll try to play with it when I get a chance, unless someone beats me to it.

                          Chris

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

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            thomthom
                            last edited by 29 Oct 2010, 06:13

                            I was thinking that the aperture was why you got entities not really visible,,, πŸ˜•

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

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              honoluludesktop
                              last edited by 29 Oct 2010, 15:09

                              Chris, I used your scanning engine in this plugin. It adjust the fov to decrease the scanning time, but it is still slow. However it will help me port, and correctly face my Cad models for visualization in Sketchup. Thanks.

                              The attached images are of a model that contains a total of 2,000 edges and 650 faces. It took about 45 seconds to check the view and reverse the back faces.

                              Test model with front and back faces.
                              Test model with back faces reversed in model view.

                              1 Reply Last reply Reply Quote 0
                              • G Offline
                                gude
                                last edited by 3 Nov 2010, 09:05

                                Chris's method along with 'deselect faces that have normals away from camera'
                                will do the task,
                                What if,
                                Just to filter the occluded faces.
                                but might be elementary
                                Is it feasible to project random points from planes in the camera.direction to test if the points do project on other planes?

                                Would it be taking too much to calculate?
                                this filter might include the partially visible ones any ways.

                                1 Reply Last reply Reply Quote 0
                                • G Offline
                                  gude
                                  last edited by 3 Nov 2010, 09:07

                                  I couldnt understand the way they did it here
                                  http://forums.cgsociety.org/archive/index.php/t-197347.html

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    thomthom
                                    last edited by 3 Nov 2010, 09:33

                                    @gude said:

                                    I couldnt understand the way they did it here
                                    http://forums.cgsociety.org/archive/index.php/t-197347.html

                                    That is the method I mentioned earlier - it selects the faces which normal is pointing towards the camera - but it doesn't take into account other faces blocking the view.

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

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

                                    Advertisement