• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

How to find loops edges from selection

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 3 Posters 131 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.
  • B Offline
    bigcatln
    last edited by 13 Nov 2012, 14:33

    Hi, everyone
    I got a problem in trying to get loops edges from a set of selection which may have more than one loops
    , and the loops may share common edge.

    My target is adding a face for each loops,it is a challenge for me,I worked for some time without no progress.
    test.jpg
    Can anyone give some advice?

    Thanks in advance

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 13 Nov 2012, 15:09

      Temporarily group the selected edges using group=model.active_entities.add_group(model.selection.to_a).
      Use group.entities.to_a.each{|e|e.find_faces}
      This will make the needed faces.
      You might now wish to check the faces' normal is the expected direction and use face.reverse if not.
      Use group.explode! to return the edges and their new faces back into their original context.

      The reason you group the edges temporarily is that other unselected edges might also form faces with the selected edges and you don't want those faces... This way only selected edges that can form faces will form faces.

      TIG

      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 14 Nov 2012, 09:18

        Or, run find_faces only on the edges that are connected only to other edges selected. ?

        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
          TIG Moderator
          last edited by 14 Nov 2012, 09:56

          @thomthom said:

          Or, run find_faces only on the edges that are connected only to other edges selected. ?
          That works... BUT it assumes that at least one of the selected edges is only connected to other selected edges [admittedly as shown in the OP's example illustration!]... BUT that method won't always work.... If the selected loop of edges contains no edges at all that are themselves only connected to the selected edges, then there'll be no edges to iterate and then no face will be formed at all. Conversely, unning find_faces on any of the edges in such a selection might form extraneous faces outside the loop, if there are other loops available to take faces.
          I was trying to offer a general solution.
          My 'temp-grouping' method ensures that if the selected edges do form a loop then a face will be made using that - irrespective of what other non-selected-edges those edges might be connected to - and no with extraneous faces resulting either.

          TIG

          1 Reply Last reply Reply Quote 0
          • B Offline
            bigcatln
            last edited by 14 Nov 2012, 13:58

            Thank you very much,TIG
            It works just like what I want,I don't find any problem up to now in my application
            The "temp grouping " method is very useful trick which avoiding unwanted face being created. 😍

            I pull each face a height, and group it, then I run into another problem, I try to delete the overlap face of each group,but failed.
            test1.JPG
            I try to use raytest method, but it only work when then two loops don't connect to each other

            	grps.each{|grp|
            		killfaces=[]
            		grp.entities.each{|fa|
            			if fa.is_a? Sketchup;;Face
            			basept=fa.bounds.center.transform! grp.transformation
            			 ray = [basept, fa.normal]
            			 item = model.raytest ray
            				if item!=nil
            				dist=basept.distance item[0] 
            				if dist < mingap
            					killfaces.push fa 
            					item[1][1].parent.entities. erase_entities item[1][1] if  item[1][1].is_a? Sketchup;;Face
            				end
            				end
            			end
            		}
            		grp.entities.erase_entities killfaces
            	}
            

            any good idea?

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 14 Nov 2012, 14:35

              If you just want to remove internal partition faces [when the forms are merged into one] then make a collection of all of the 'flat' edges in the extrusions [ edge.start.position.z==edge.end.position.z ] and collect any of those with edge.faces.length > 2, then you can erase them if two of that edges faces have face.normal.parallel?(Z_AXIS). This keeps any vertical edges perhaps needed at changes of direction in plan... An inner face can't survive without all of its edges, and we are removing any 'flat' ones...

              Otherwise you'll need some very convoluted face.classify_point() combined with some raytest methods [and transformations] to work out which of the edges' faces are the internal ones and then erase them - see tools like my SolidSolver...

              TIG

              1 Reply Last reply Reply Quote 0
              • B Offline
                bigcatln
                last edited by 14 Nov 2012, 15:51

                thanks TIG, I worked it out by classify_point and raytest

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

                Advertisement