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

    Select smoothed faces as if they were one face?

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

      Is there a built in way to easily select faces that have edges smoothed together to make it appear like a single face? So, like think of a sphere with hidden geometry on. You can see its made up of a bunch of faces. With hidden geometry showing, you can see each face and selsect each individually. But with hidden geometry off, it appears as a single big face. Select one and you select them all.

      Is there a way to run through a model and get each array of faces that makes up each larger group of faces? Does that make sense?

      I have some ideas how to write a method that loops through and does this, but I thought there might be a method that helps do this quicker. Thanks,

      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

        Do you want to get an array of connected smoothed faces from one give face?
        Or do you want multiple arrays of all smoothed faces?

        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

          The end product that I will need is a single array that contains arrays of connected/smooth faces.

          faces = [face1, [face2, face3, face4], face5, [face6, face7], face8, [face9, face10, face 11]]

          But just figurung out how to make a single array per group of smoothed faces is enough. I can then turn them into an array like I've shown above.

          I was thinking a recursive method? (I'm sort of guessing at the terms here). But one that I give a face name. Its job is to find all connected edges and determine if they are softe/smoothed. If yes, then it finds the other common face to that line and sends it back into the same method. It would then keep going until all faces that were connected have been run through the method and all edges have been tested to see if they are soft/smoothed.

          Does that sound sort of logical? I know I will need to keep track of various things like edges that have been run already, and faces and such. I think I remember you running into an issue with recursive scanning like this. Is that something I should worry about?

          Chris

          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,

            Here is a piece of code that I use in my scripts.
            You can adapt the test on Edges (hidden?, smooth?, soft?) to your own need.

            
            #Determine all connected faces to the face (i.e. if bording edge is soft or hidden)
            #note; the recursive version seems to bugsplat on big number of faces. So I use an iterative version
            
            def face_neighbours(face)
            	hsh_faces = {}
            	lface = [face]
            	
            	while true
            		break if lface.length == 0
            		f = lface[0]
            		if hsh_faces[f.entityID]
            			lface[0..0] = []
            			next
            		end	
            		lface[0..0] = []
            		hsh_faces[f.entityID] = f
            		f.edges.each do |e|
            			if e.hidden? || e.soft?
            				e.faces.each do |ff| 
            					lface.push ff unless ff == f || hsh_faces[ff.entityID]
            				end	
            			end	
            		end
            	end	
            	hsh_faces.values
            end
            
            

            Fredo

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

              Recursing is no good for this kind of thing. It doesn't take too much geometry before you create a stack overflow and bugsplat SU. I had major pains with that when I first made my Selection Toys plugin. Besides, after reading up on stack overflows and recursive loops, recursive loops is often inefficient.

              Fredo's solution is the way to go. That's the method I ended up with as well. Build and array of the elements you want to process as you traverse your geometry and make a loop that runs until you've processes the whole array.

              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

                Whaat, its taken me some time to get back to this, but a HUGE thank you! This does the trick quite well. I send it a face and it gives me back all connected faces. I then can remove those faces from my selection set so as to not re-examine them. Absolutely brilliant. This will get written into my components onto faces script. Hopefully have it done and updated tonight. Thanks a million,

                Chris

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

                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