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

    [Req] Check for N-Gons

    Scheduled Pinned Locked Moved Plugins
    25 Posts 6 Posters 3.3k 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      @remus said:

      TIG, i realise the current script only works in the current context (in a group etc.), it was on purpose as i thought it was more useful than only being able to check the faces in the highest context.

      On another note, does entities not include faces, edges etc. that are within components? If so that would explain why khai was having trouble with it...

      active_entities is everything in the current edit session - i.e. in the model or a group or component being edited.
      entities is everything in the model - as in model.entities but stops short of nested stuff so it lists all geometry, groups, instances etc.
      You also use entities for other containers like groups or component_definitions - e.g. group.entities and definition.entities. again these stop short of listing nested stuff.
      To find ALL entities you need to do my trick of iterating through the model.definitions and going through the entities of each definition...
      Remember too that if you are changing entities always use an array as in ents.to_a - changing entities as you ' each' loop through them leads to unpredictable results as the entities list constantly changes and so it becomes confused...

      TIG

      1 Reply Last reply Reply Quote 0
      • R Offline
        remus
        last edited by

        Cheers for the explanation πŸ‘

        http://remusrendering.wordpress.com/

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

          presto reserectus!

          http://forums.sketchucation.com/viewtopic.php?f=169&t=24681&p=247955#p247955

          I'm wondering if this can be expanded now to highlight the Ngons? we're finding with Sculptis it rejects any faces with more than 4 faces....

          1 Reply Last reply Reply Quote 0
          • R Offline
            remus
            last edited by

            Try this in the webconsole. To be honest your probably better off using TIGs triangulate faces ruby, though...

            model = Sketchup.active_model
            entities = model.active_entities
            selection = model.selection
            
            n = 0
            
            entities.each{|e|
              if e.is_a? Sketchup;;Face
                if e.edges.length > 4
                  n += 1
                  selection.add(e)
                end      
              end
            }
            
            if n > 0
              UI.messagebox("Contains N-Gons (Faces with >4 sides)")
            else
              UI.messagebox("N-gon free!")
            end
            

            http://remusrendering.wordpress.com/

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

              webconsole?

              and I explained back in this thread.. I can't tri the mesh. I'm moving from here (I love the modeler!) to app that don't like things being totally tri's... so that ruby's no good to me.

              1 Reply Last reply Reply Quote 0
              • R Offline
                remus
                last edited by

                Webconsole is a handy little ruby that lets you run bits of ruby in SU without having to package it as a separate file. You can find it here: http://sketchuptips.blogspot.com/2007/08/plugin-webconsolerb.html

                Just install it as usual, open SU, hit the appropriate menu item, copy and paste the code in and click run.

                I'll get going on a normal version, but no promises. Its been a while since ive written a ruby.

                http://remusrendering.wordpress.com/

                1 Reply Last reply Reply Quote 0
                • R Offline
                  remus
                  last edited by

                  Ok, here you go.

                  Several improvements in v.3:
                  works over the entire model (in groups and components), thanks to TIGs handy little snippet.
                  Adds all N-gons to a new selection
                  Tells you how many N-Gons there are in the model
                  Added a Tri check which can be accessed by typing tri_check() in to the ruby console


                  ngon_check.rb

                  http://remusrendering.wordpress.com/

                  1 Reply Last reply Reply Quote 0
                  • StinkieS Offline
                    Stinkie
                    last edited by

                    Thanks!

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

                      not working right.... it's reporting everything has 18 N-gons... even a cube.....

                      wish I could help 😞 but I'm no programmer 😞

                      1 Reply Last reply Reply Quote 0
                      • R Offline
                        remus
                        last edited by

                        Hmmm, most unusual. Working ok for me. Could you post a problem model?

                        http://remusrendering.wordpress.com/

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

                          no point.. since even a simple six sided cube is reporting '18 Ngons' tho, if I add 3 Ngons... it reports '21 Ngons' !

                          for some reason it's reporting 18 instead of 0....

                          Edit

                          Found the problem. it's checking all the entities in the scene. example : a new scene automatically has 18 Ngons = the default human figure.

                          even deleting him, he registers in the Ngon check.. do a purge and remove him totally, it reports correctly...

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

                          Advertisement