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

[Plugin] 2dBoolean ver1.3.1 beta UPDATE 20 dec 2013

Scheduled Pinned Locked Moved Plugins
88 Posts 8 Posters 48.8k 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.
  • J Offline
    jolran
    last edited by 31 Aug 2011, 15:17

    OK, got it! hopefully

    Made a group of faces from face.clone holes. Took their face.bounds.centers.
    Then compared cutting.components (faces.center.bounds) to those other centers.
    Since center is a point=position I could use ==comparison. Just delete face if they where in the same position..

    The code can probably be optimized, but first do some testing and see if it holds!

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 31 Aug 2011, 16:30

      πŸ˜• Why are you still using 'face clone holes' and 'bounds center' ??? πŸ˜•
      You are still making it too complex...
      Simply use the group that is to be trimmed and intersect group.entities with the face.edges+[face], placing the results in the group.entities.
      If the original thing to 'trim' is a component-instance, as I tried to explain... make it into a group...
      group=instance.parent.entities.add_group(instance) instance.explode
      NOW inspect the group.entities to get unneeded off-face edges and then remove them [as explained]...

      After you're done every thing IF desired then exploding the group will merge it with the face ? [you could erase the face first]

      TIG

      1 Reply Last reply Reply Quote 0
      • J Offline
        jolran
        last edited by 31 Aug 2011, 16:58

        Gee!! πŸ‘Š Now I get what you are saying..

        Explode the COLORED face.group onto the face.clone. I did not get that part.

        OK I will try your method now. Thanks.

        1 Reply Last reply Reply Quote 0
        • J Offline
          jolran
          last edited by 31 Aug 2011, 18:31

          I'm sorry. Tried to do what you said, or what I think you mean. 😳

          But still don't understand how the faces in holes are supposed to disapear when merging them(exploding) onto the face.
          This is done after intersection and trimming the edges..

          Just to make sure we talk about the same entities here. face.edges+[face] is the face.clone.entities right?

          Group is the selected component or group in Sketchup(turned into a group by definition).

          Now, to be able to explode the group onto face.clone the group off course have to be inside face.clone group=gp.

          Then after all that, the last step is to transform the group and turn it into a cutting component.

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 31 Aug 2011, 18:54

            We still speak at cross-purposes πŸ˜’

            Try to 'forget' everything so far...

            Your code already finds the 'face' and 'group' that is overlaid on it that we need.
            [if it's a component-instance you first add it to a group [explode it] and use that group].
            You can then use the group.entities.intersect_with()...
            Add the intersection geometry into group.entities made when it intersects with (face.edges+[face]).
            We now have a group containing all of the edges and faces needed.
            Some of these are in holes in the face or outside of the face altogether.
            To find these iterate all edges in the group.entities, compose an array of any edges which fail a set of face.classify_point() tests on the edge's midpoint - an edge passes and is NOT erased if it is ON the face [in off or in a hole], OR on a face's edge, OR on a face's vertex. Otherwise it fails.
            When you have the list of 'edges2go' you erase them en mass.
            Now you should have a group with all edges/faces trimmed to the perimeters of the face - including any holes in the face...
            At this point the group is laid on the face and will z-fight between the faces.

            You can them convert that group into a gluing cutting component with appropriate axes and in the same transformation, glued_to the face...
            You can then offer the user the chance to explode the group and merge the group's trimmed faces and the original face...
            πŸ˜•

            TIG

            1 Reply Last reply Reply Quote 0
            • J Offline
              jolran
              last edited by 31 Aug 2011, 19:29

              Ahh ok. That is more streamlined. πŸ˜„

              SS=Sketchup.active_model.selection-face. So no face.clone is needed then?

              @unknownuser said:

              When you have the list of 'edges2go' you erase them en mass.
              Now you should have a group with all edges/faces trimmed to the perimeters of the face - including any holes in the face...

              This I still am not convinced about. You have to forgive me if I seam like a stuborn idiot, but please look at the picture. There will be 1 face remaining if we only delete edges2go. ❓

              OR do you mean it will go away after the intersection? I havent tested yet.


              Faced with a problem-1.jpg

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 31 Aug 2011, 21:29

                β˜€
                At last I can see the issue too. πŸ˜’
                I was missing some points in one of your earlier posts. 😳
                So... after all of the edges2go are collected and erased we might still have some 'never-split' faces over 'holes' that will still need to be removed, or also such faces over 'holes' that are abutting a 'perimeter' of the face.

                Therefore we MUST go back to earlier ideas... πŸ˜’ πŸ˜’

                After the midpoint tests of the group's edges and the 'edges2go' tidy up [which WILL remove a lot of unwanted dross] we MUST examine the group's faces in turn.
                We can get a point on each of these faces and test it using face.classify_point(pt) if it returns as 'off the face' [i.e in a hole] then we .erase! it.
                Finally we then do a final 'tidy up' - i.e. removing faceless-edges left after unwanted faces are removed.

                Here's the whole test/fix...
                faces=[] group.entities.each{|e| faces << e if e.class==Sketchup::Face } tedges=[] faces.each{|gface| pt=gface.bounds.center.project_to_plane(face.plane) if face.classify_point(pt)==Sketchup::Face::PointOutside tedges << gface.edges gface.erase! end } tedges.flatten! tedges.uniq! tedges.each{|e| e.erase! if e.valid? and not e.faces[0] }

                Once that's all done we can worry about making the group into the gluing/cutting component, with corrected axes as before... 😲

                TIG

                1 Reply Last reply Reply Quote 0
                • J Offline
                  jolran
                  last edited by 31 Aug 2011, 21:59

                  He he! No worries πŸ˜„

                  Sometimes when I reread my posts I wonder what the heck I was talking about. That's why I post so many pictures πŸ˜„ To clear things up.

                  This new code of yours look very nice. Can't wait to test it out.

                  @unknownuser said:

                  tedges.uniq!

                  Haven't seen that command before? To remove duplicates? Need to read more about pure Ruby...

                  @unknownuser said:

                  Once that's all done we can worry about making the group into the gluing/cutting component, with corrected axes as before...

                  I was thinking of putting in the option to make group instead of component, should one wish. Could be useful if the user only has edges with no faces.

                  Thanks a lot for your help, TIG!

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jolran
                    last edited by 1 Sept 2011, 06:41

                    I'm having trouble with this part of the code. Maybe should add some parameters to it?

                    faces.each{|gface|
                    pt=gface.bounds.center.project_to_plane(face.plane)
                    if face.classify_point(pt)==Sketchup;;Face;;PointOutside
                    tedges << gface.edges
                    gface.erase!
                    end
                    }
                    

                    If you look at the picture, you will see that it might not work in all cases with that code.
                    Especially when having big faces.

                    In the earlier posts I was trying to figure out a way to erase faces more selectively.
                    By using IF the FACES center==HOLES center >> erase.faces! (Simplified code)

                    However, when I did that, sometimes there where errors. Or faces that would not get deleted.


                    Faced with a problem-2.jpg

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 1 Sept 2011, 09:58

                      The .flatten! combines nested arrays
                      The .uniq! removes duplicates
                      Also [not applicable to THIS tool] .compact! would remove 'nil' array elements, or .sort! puts the list 'in order'...

                      Now to the chase.........
                      I also see this 'unexpected' possibility of faces we want to keep being false-flagged as 'holes'.
                      So we need to trap for real 'hole' faces - the outer_loop edges will always have two faces...

                      faces2go=[]### rather than erase as we go we'll collect them...
                      faces.each{|gface|
                        ### we skip the gface IF it's NOT a 'hole'
                        ### just 1 one-faced edges is enough for != hole
                        hole=true
                        gface.outer_loop.edges.each{|e|
                          if e.faces.length==1
                            hole=false
                            break
                          end
                        }
                        next if not hole
                        ###
                        pt=gface.bounds.center.project_to_plane(face.plane)
                        if face.classify_point(pt)==Sketchup;;Face;;PointOutside
                          tedges << gface.edges
                          faces2go << gface ### save them up
                        end
                      }
                      
                      

                      THEN erase_entities on faces2go and then erase! any of the tedges that don't have a face...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        jolran
                        last edited by 1 Sept 2011, 13:01

                        @unknownuser said:

                        The .flatten! combines nested arrays
                        The .uniq! removes duplicates
                        Also [not applicable to THIS tool] .compact! would remove 'nil' array elements, or .sort! puts the list 'in order'...

                        πŸ‘ Great to know. Will be useful.

                        Your code works! Almost

                        Like with the method I used before(face.clone holes.centers), I'm experiencing some faces don't get erased. (Having a model that look like a swiss cheese)

                        I wonder why this happends. Your code should be working...

                        For ex. I run the plugin once. Maybe 3 faces are not deleted but the edges are trimmed to fit. I run the plugin again with the component selected, then it is OK!

                        It is like it needs another rescue operation? πŸ˜• Or maybe run the last command twice? Seems excessive..

                        I will check my code as well. Been moving snippets back and forth, it need some cleaning up.

                        And another thing. Was it GO for NOT using faceclone? Intersect with SS or Glue face?
                        I havent implemented that yet, still using face.clone. Shouldent matter in this regard...


                        Almost.jpg

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          jolran
                          last edited by 1 Sept 2011, 15:02

                          Think it is ok...

                          Breaks sometimes, but only if using a simple squarish component. One have to consider what this tool is going to be used for.

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            TIG Moderator
                            last edited by 1 Sept 2011, 15:10

                            Try intersecting the group.entities with the face.edges+[face] twice ?
                            Will make it slightly slower... BUT it might fix the potential glitch ??

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • J Offline
                              jolran
                              last edited by 1 Sept 2011, 15:34

                              Yes TIG, I think you are on the right track there! Good thinking.

                              I was about to report that intersection is not working properly. One cannot erase a face if it can't be selected πŸ˜„

                              This can be due to my code being a bit shabby at the moment, moving stuff back and forth as mentioned.

                              I will "clean it" and report back later.

                              1 Reply Last reply Reply Quote 0
                              • J Offline
                                jolran
                                last edited by 1 Sept 2011, 23:27

                                2 intersection gave a big improvement! Not 100% accurate, but I think it's good enough. One can force it by selecting the component and running the plugin again. It almost always sort out the fuzz, then.

                                Still intersecting with face.clone. Had some problem with intersecting with Sketchup.active.model selection...Expecting entitiy something..

                                Speed is better, even with 2 intersections πŸ˜‰

                                Did a test with a "heavy" component, ver 1.1 VS current dev.code. VER 1.1: 41.483 seconds. current dev.code: 4.278 seconds 😲

                                Do we move forward, TIG? Or delve deeper in this problem, to make perfection?


                                2 intersections.jpg

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  jolran
                                  last edited by 2 Sept 2011, 09:16

                                  Ok, I have put out the new version 1.2 for testing. So you have something to play with this weekend.
                                  It should be an improvement..

                                  KEEP THE OLDER VERSION AT HANDS! I won't be able to fix issues this weekend πŸ˜„

                                  Thank you TIG for all the help.

                                  I haven't optimized the iterator exactley as TIG suggested, so that can be improved...

                                  There are more issues to deal with later on.. But let's not spoil all the fun.

                                  1 Reply Last reply Reply Quote 0
                                  • andybotA Offline
                                    andybot
                                    last edited by 7 Oct 2011, 17:27

                                    Joel, thanks so much for this plugin!! I have 2d elevations that I needed to glue to a massing, and this works absolutely perfect for my needs. Good work!
                                    Andy

                                    http://charlottesvillearchitecturalrendering.com/

                                    1 Reply Last reply Reply Quote 0
                                    • A Offline
                                      AcesHigh
                                      last edited by 7 Oct 2011, 22:40

                                      can anyone check if this pluging works with meshes?

                                      when importing several pieces from GoogleMaps, the pieces usually end overlapping each other, causing texture errors.

                                      You cant use 3D boolean because obviously, meshes, are not solids.

                                      So I would usually "zorro" the different meshes, and cut the parts that overlap. Obviously, a HUGE work when you are dealing with dozens of different GoogleEarth imported meshes. If this plugin works with those, it will be great!

                                      1 Reply Last reply Reply Quote 0
                                      • J Offline
                                        jolran
                                        last edited by 8 Oct 2011, 19:12

                                        Hey, I missed some posts in here!

                                        Andybot. I'm glad someone have use for this plugin! Appreciate it!(we all know TIG's part of this of course)

                                        AcesHigh.

                                        I've seen your request in other post regarding this subject. Like I said. I think it lies more in the 3d domain, since the surfaces are not flat.

                                        IF the intersecting geometry would be flat at intersectionpoints, 2dBoolean should activate. But I see your case you would need a subtraction-algorythm.

                                        At this point 2dboolean only subtracts geometry outside the face it's lying on(or selected face).

                                        What you are asking for is really needed, and I will see what can be done about that in the future. I'm kinda busy at the moment.

                                        Have to deal with Hatchfaces webdialog, which unfortunaly proves very difficult.
                                        I thought I only had to learn Javascript, HTML, CSS and JQUERY πŸ˜‰ . But there is need for some JSON and maybe AJAX as well. Kinda much required to make a simple dialog if you ask me.

                                        1 Reply Last reply Reply Quote 0
                                        • J Offline
                                          jolran
                                          last edited by 29 Nov 2011, 14:32

                                          Nice update.

                                          But! If you are gonna further developp this tool, and display it in this thread with my icons included. Please don't scramble the code, so other can benefit from your code like you did on mine and Tig's.

                                          Besides your plugin will be lost in this thread posting it here.

                                          Best regards.

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

                                          Advertisement