sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Plugin] Face Flattener 0.19

    Scheduled Pinned Locked Moved Plugins
    50 Posts 29 Posters 53.9k Views 29 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.
    • W Offline
      watkins
      last edited by

      Dear Ray,

      I tried out your script on the following simple model.

      Draw a rectangle, say 100 mm by 100 mm, and then pull it up 10 mm into a 3D shape.
      Use the move tool to pull up one corner on the top face by 0.1 mm.
      Draw a few lines on the sides to divide areas into two, and perhaps a few random, un-terminated lines on various surfaces.
      Select all and run your script.

      When I do this I lose the top face. Interestingly enough this also happens when I run the script cleanup_model.rb (by John H. Aughey). The script deletecoplanaredges.rb (by Jack Dolabany)removes all redundant co-planar lines, but leaves the top face with its centre fold untouched.

      I imagine that this is not what you had in mind.

      Kind regards,
      Bob

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

        thanks, will be very useful

        THREEDIMENSIONSWEB dot COM

        1 Reply Last reply Reply Quote 0
        • cerevellumC Offline
          cerevellum
          last edited by

          Hi Ray and Bob,

          This is something I've noticed while working on my flattening script, and I still haven't figured out why it happens. The simplest way of reproducing this is to draw a box, add a rectangle to the top surface and connect it with a line to the outer edge loop. When erasing one of the edges of the rectangle that was added, both faces disappear.

          edgeFaceEraseExFinalA.jpg

          However, if you were to erase the edge that connects both edge loops first, then you can erase the edges of the inside rectangle just fine. It apparently has to do with the order in which you erase coplanar edges. Delete edges in the following order: edges connected to 0 faces go first, then edges connected to 1 face, and finally edges connected to 2 faces.

          edgeFaceEraseExFinalB.jpg

          See ya,
          Zach

          1 Reply Last reply Reply Quote 0
          • W Offline
            watkins
            last edited by

            Dear Zach,

            The script deletecoplanaredges.rb failed your example too, so some recoding is needed to get a more reliable cleanup script.

            Regards,
            Bob

            1 Reply Last reply Reply Quote 0
            • GaieusG Offline
              Gaieus
              last edited by

              @cerevellum said:

              Hi Ray and Bob,

              This is something I've noticed while working on my flattening script, and I still haven't figured out why it happens. The simplest way of reproducing this is to draw a box, add a rectangle to the top surface and connect it with a line to the outer edge loop. When erasing one of the edges of the rectangle that was added, both faces disappear...

              Ha! Beautiful! I love these "glitch hunts". And you cannot even heal the face by redrawing an edge of it until you get rid of the leftover geometry in the middle! ๐Ÿ‘

              Gai...

              1 Reply Last reply Reply Quote 0
              • W Offline
                watkins
                last edited by

                Dear Gaieus,

                Perhaps some of our script writers could come up with a more reliable clean-up script.

                I note from Zach's example that the line joining the inner and outer loops is bounded by the same area, while the lines forming the inner and outer loops are bounded by different areas. What makes an area/surface unique, and could this be used to decide on the order of line removal? At least deletecoplaredges.rb leaves the centre fold line in an non-coplanar surface alone, and so perhaps this would be the script to start with. A nice icon would not go amiss, say an image of a few random, crossed lines.

                Kind regards,
                Bob

                1 Reply Last reply Reply Quote 0
                • GaieusG Offline
                  Gaieus
                  last edited by

                  Bob, Zach,

                  I have a script that creates a menu item "Remove unused edges" in the Edit menu (for the life I cannot locate the script anywhere to see the file name of it). Using the script it also deletes the top surface (so the order it deletes the lines must be wrong as well).

                  I have noticed a couple of times that using it leads me to lose a coupleof faces (especially after complex, curved intersections).

                  Gai...

                  1 Reply Last reply Reply Quote 0
                  • W Offline
                    watkins
                    last edited by

                    Dear Gaieus,

                    It is cleanup_model.rb.

                    Regards,
                    Bob

                    1 Reply Last reply Reply Quote 0
                    • GaieusG Offline
                      Gaieus
                      last edited by

                      Ah, thanks a bunch, Bob! I have always wondered and couldn't figure out (I keep a fairly nice mess in my Plugins folder).

                      Gai...

                      1 Reply Last reply Reply Quote 0
                      • RayOchoaR Offline
                        RayOchoa
                        last edited by

                        You know what i don in order to get a 2d model is get the scale tool and type in .002 and then do that again by putting a line next to it and resizing again. then i just erase the lines i want after intersecting everything

                        CaR DeSiGnS bY mE
                        http://ray-ochoa.com

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

                          โ— Perfect solution: export-import 2D hidd.line mode dwg.
                          Not sure it canbe implemented in .rb though

                          1 Reply Last reply Reply Quote 0
                          • F Offline
                            Fletch
                            last edited by

                            RE: Face flattener - I'll give it a shot... thanks for sharing!

                            Ray, and others, when wanting to export a flat model from SU to CAD format - don't forget the Automated 2D Output ruby! Then you can just re-import the .dwg file back into SU, and it will be flat.

                            Fletch
                            Twilight Render Cross-platform Plugin for SketchUp on PC or Mac

                            1 Reply Last reply Reply Quote 0
                            • Z Offline
                              zhuangsuph
                              last edited by

                              1 Reply Last reply Reply Quote 0
                              • wzfwzfwzfW Offline
                                wzfwzfwzf
                                last edited by

                                hehe,hello.

                                1 Reply Last reply Reply Quote 0
                                • fredo6F Offline
                                  fredo6
                                  last edited by

                                  @cerevellum said:

                                  Hi Ray and Bob,

                                  This is something I've noticed while working on my flattening script, and I still haven't figured out why it happens. The simplest way of reproducing this is to draw a box, add a rectangle to the top surface and connect it with a line to the outer edge loop. When erasing one of the edges of the rectangle that was added, both faces disappear.

                                  What you can try to possibly avoid this problem is to calculate all coplanar segments, not delete them, but instead put them in a list (or in the selection). Then, just delete the entities in the list (or in the selection):

                                  
                                  model.entities.erase_entities list_edges
                                  #or
                                  model.entities.erase_entities model.selection
                                  
                                  

                                  It seems to work fine on your example, and on some more complex configurations, but I did not try in the general case.

                                  Note: manually in Sketchup, what I would use is to select all coplanar segments, put them in a group and then just delete the group. It leaves all faces intact. Unfortunately, there is no method in Ruby to make a group or a component out of existing elements!

                                  1 Reply Last reply Reply Quote 0
                                  • Z Offline
                                    zhuangsuph
                                    last edited by

                                    1 Reply Last reply Reply Quote 0
                                    • M Offline
                                      marne
                                      last edited by

                                      @unknownuser said:

                                      Thanks Zack.
                                      This could prove really useful for the bad AutoCad imports I sometimes get.

                                      Yip, so true for me too ๐Ÿ˜• . Very useful. Thanks for this script!

                                      1 Reply Last reply Reply Quote 0
                                      • F Offline
                                        Fletch
                                        last edited by

                                        @cerevellum said:

                                        The order of operations:

                                        1. Select some geometry
                                        2. Right click, select Flattening Script
                                        3. Left click on a face (this decides the plane the geometry will project to)

                                        This doesn't work for me at all. please test on attached scene.

                                        1. select all the geometry on the lower plane
                                        2. Right click, select Flattening Script
                                        3. Left click on a face above

                                        FlatteningTest.zip


                                        flat-1-bug.jpg


                                        flat-2-bug.jpg

                                        Fletch
                                        Twilight Render Cross-platform Plugin for SketchUp on PC or Mac

                                        1 Reply Last reply Reply Quote 0
                                        • C Offline
                                          chango70
                                          last edited by

                                          This seem like a useful script, shame it is still on 0.19.

                                          1 Reply Last reply Reply Quote 0
                                          • cerevellumC Offline
                                            cerevellum
                                            last edited by

                                            @Fletch
                                            Hey, I took a look at the test model. The script doesn't work on curves yet. Basically, if you were to explode any curves it should work fine!

                                            @chango70
                                            Yeah, I stopped working on this script a while back (1 year?). Hopefully, I will be able to finish it up soon enough. Probably will ensure this script works inside Groups and works with curves as well.

                                            Thanks! BTW, the original version of this had an arbitrary axis, something that could be useful as well. Perhaps the next steps are to rework the code to include this feature, or maybe to include a dialog box with several options to choose from?

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

                                            Advertisement