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

    How to get face which is belong to two group

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 4 Posters 537 Views 4 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.
    • Y Offline
      YoungOSG
      last edited by

      there are two groups .i wanna to get the face ,which is belong to two groups.just like two walls,there is a face which can be think to belong any wall.
      as the picture.
      how can i can get the face?
      thanks


      ![[7DSPY@EF_WPWXB8)3XSO8.jpg

      1 Reply Last reply Reply Quote 0
      • cottyC Offline
        cotty
        last edited by

        If there is one face (in one of the groups) or if there are two faces (one in each group) depends on the way you created the groups. You can always enter one group, copy the face to the clipboard and paste (in place) it outside those groups to get a single face independent of the groups.

        my SketchUp gallery

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

          Almost the same answer as Cotty above (posted while I was typing):

          Think of a group as a container or a room in a house. An object can't be in two containers / rooms at the same time - it can only be in one container / room / group at the same time.

          So, you have several options:

          1. make a copy of 'the face' and put them in both groups
          2. make an extra third group and put 'the face' in it. Now it doesn't belong to either groups but is a unique group itself.
            3)...

          The best choice depends on what you're trying to achieve.

          1 Reply Last reply Reply Quote 0
          • Y Offline
            YoungOSG
            last edited by

            @cotty said:

            If there is one face (in one of the groups) or if there are two faces (one in each group) depends on the way you created the groups. You can always enter one group, copy the face to the clipboard and paste (in place) it outside those groups to get a single face independent of the groups.

            i think i don't explain it clearly. there are two faces (one in each group),as you say. and when i explode two groups,i can get 11 faces which 1 face is delete.
            i wanna use api to get this face in groupA which in groupB also has this face .i mean they are occupy same region.but they are different.
            can i do it by judge face's vertices position or some other ways?

            1 Reply Last reply Reply Quote 0
            • cottyC Offline
              cotty
              last edited by

              @youngosg said:

              i wanna use api to get this face

              So this is a ruby question? I've moved this topic...

              my SketchUp gallery

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                Get

                tr1=group1.transformation
                tr2=group2.transformation
                

                You need those th apply to things later...

                The two 'coincident' faces in question will have some similar properties [when adjusted for their container's transformation].
                You need to iterate the faces in group1 to get a suitable in group2

                faces1=group1.entities.grep(Sketchup;;Face)
                faces2=group2.entities.grep(Sketchup;;Face)
                face2=nil
                face1=nil
                faces1.each{|face|
                  min=face.bounds.min.transform(tr1)
                  max=face.bounds.max.transform(tr1)
                  norm=face.normal.max.transform(tr1)
                  faces2.each{|f|
                    if f.bounds.min.transform(tr2)==min && f.bounds.max.transform(tr2)==max && f.normal.transform(tr2)==norm.reverse
                      face2=f
                      face1=face
                      break
                    end
                  }
                  break if face2
                }
                ### face2 is the matching face in group2, if not nil !  Delete it !
                ### face1 is the matching face in group1
                

                This is NOT foolproof.
                BUT you can add extra tests...
                For example... collect the loops of face2, collect their vertices as points and transform them, then compare with the loop-vertices-points-transformed of face1, if there are any mismatches then the two faces are NOT completely coincident - e.g. one of the otherwise coincident could have a side-notch or a hole in it, but still have the same normal and bounds !
                You need to make these decisions... Simple boxes ?

                TIG

                1 Reply Last reply Reply Quote 0
                • Y Offline
                  YoungOSG
                  last edited by

                  @tig said:

                  Get

                  tr1=group1.transformation
                  > tr2=group2.transformation
                  

                  You need those th apply to things later...

                  The two 'coincident' faces in question will have some similar properties [when adjusted for their container's transformation].
                  You need to iterate the faces in group1 to get a suitable in group2

                  faces1=group1.entities.grep(Sketchup;;Face)
                  > faces2=group2.entities.grep(Sketchup;;Face)
                  > face2=nil
                  > face1=nil
                  > faces1.each{|face|
                  >   min=face.bounds.min.transform(tr1)
                  >   max=face.bounds.max.transform(tr1)
                  >   norm=face.normal.max.transform(tr1)
                  >   faces2.each{|f|
                  >     if f.bounds.min.transform(tr2)==min && f.bounds.max.transform(tr2)==max && f.normal.transform(tr2)==norm.reverse
                  >       face2=f
                  >       face1=face
                  >       break
                  >     end
                  >   }
                  >   break if face2
                  > }
                  > ### face2 is the matching face in group2, if not nil !  Delete it !
                  > ### face1 is the matching face in group1
                  

                  This is NOT foolproof.

                  BUT you can add extra tests...
                  For example... collect the loops of face2, collect their vertices as points and transform them, then compare with the loop-vertices-points-transformed of face1, if there are any mismatches then the two faces are NOT completely coincident - e.g. one of the otherwise coincident could have a side-notch or a hole in it, but still have the same normal and bounds !
                  You need to make these decisions... Simple boxes ?

                  thanks! you always be the super star 😍

                  1 Reply Last reply Reply Quote 0
                  • Y Offline
                    YoungOSG
                    last edited by

                    @tig said:

                    Get

                    tr1=group1.transformation
                    > tr2=group2.transformation
                    

                    You need those th apply to things later...

                    The two 'coincident' faces in question will have some similar properties [when adjusted for their container's transformation].
                    You need to iterate the faces in group1 to get a suitable in group2

                    faces1=group1.entities.grep(Sketchup;;Face)
                    > faces2=group2.entities.grep(Sketchup;;Face)
                    > face2=nil
                    > face1=nil
                    > faces1.each{|face|
                    >   min=face.bounds.min.transform(tr1)
                    >   max=face.bounds.max.transform(tr1)
                    >   norm=face.normal.max.transform(tr1)
                    >   faces2.each{|f|
                    >     if f.bounds.min.transform(tr2)==min && f.bounds.max.transform(tr2)==max && f.normal.transform(tr2)==norm.reverse
                    >       face2=f
                    >       face1=face
                    >       break
                    >     end
                    >   }
                    >   break if face2
                    > }
                    > ### face2 is the matching face in group2, if not nil !  Delete it !
                    > ### face1 is the matching face in group1
                    

                    This is NOT foolproof.

                    BUT you can add extra tests...
                    For example... collect the loops of face2, collect their vertices as points and transform them, then compare with the loop-vertices-points-transformed of face1, if there are any mismatches then the two faces are NOT completely coincident - e.g. one of the otherwise coincident could have a side-notch or a hole in it, but still have the same normal and bounds !
                    You need to make these decisions... Simple boxes ?

                    one more question.if there are many groups,how can i get the groupA which is adjacent with groupB.
                    i intend to judge by distance.is there any easy way to do this?

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      Try the groups' .bounds if they 'touch', then some_group.bounds.max.x OR .y OR .z and some_other_group.bounds.min.x OR .y OR .z might be coincident ??
                      Especially if the are simple boxes...

                      TIG

                      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