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

    Method or plugin for subdividing like this sample

    Scheduled Pinned Locked Moved Developers' Forum
    31 Posts 7 Posters 4.6k Views 7 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.
    • C Offline
      cesaro36
      last edited by

      Hi everyone
      Is there any plugin or code snippet that creates this kind of subdivision, basically is a offset from each edge in a solid component?
      My goal is to smooth corners at objects prior to any rendering.
      Corner subdivision

      Saludos

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        mod = Sketchup.active_model
        ent = mod.active_entities
        sel = mod.selection
        vue = mod.active_view; pts =[]
        sel.grep(Sketchup;;Face).each{|f|
         vec = f.normal.reverse
         pts << f.vertices.map{|v|v.position.offset(vec)}
        }
        pts.each{|p| f=ent.add_face(p); f.erase!}
        
        

        subdividing.gif

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

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

          How simple you make it look like.
          Thanks. I'll dig into it.

          1 Reply Last reply Reply Quote 0
          • PixeroP Offline
            Pixero
            last edited by

            Thanks for the code Sam. πŸ‘

            It works great for the example where faces are perpendicular but not with something with non perpendicular faces. See attached SKP (SU8). Could that be added?

            Offset problems.skp

            1 Reply Last reply Reply Quote 0
            • sdmitchS Offline
              sdmitch
              last edited by

              @pixero said:

              It works great for the example where faces are perpendicular but not with something with non perpendicular faces.

              mod = Sketchup.active_model
              ent = mod.active_entities
              sel = mod.selection
              vue = mod.active_view; pts =[]
              faces = sel.grep(Sketchup;;Face)
              faces.each{|f|
               vec = f.normal.reverse; ctr = f.bounds.center
               pts << f.vertices.map{|v|v.position.offset(ctr.vector_to(v.position)).offset(vec)}
              }
              grp=ent.add_group; ge=grp.entities; gt=grp.transformation
              pts.each{|p|
               fgrp=ent.add_group;fge=fgrp.entities;fgt=fgrp.transformation
               f=fge.add_face(p);
               fge.intersect_with false,fgt,ge,gt,false,faces
               fgrp.erase!
              }
              grp.explode
              
              

              Nothing is worthless, it can always be used as a bad example.

              http://sdmitch.blogspot.com/

              1 Reply Last reply Reply Quote 0
              • PixeroP Offline
                Pixero
                last edited by

                I tried the new code and it's better but for other non perpendicular faces it still gives some weird results.
                A cylinder for example.
                I have attached another example of that below. Hopefully it's possible to get it right for these cases also.

                Offset errors 2.skp

                1 Reply Last reply Reply Quote 0
                • sdmitchS Offline
                  sdmitch
                  last edited by

                  @pixero said:

                  A cylinder

                  The initial request was for a simple box.

                  Nothing is worthless, it can always be used as a bad example.

                  http://sdmitch.blogspot.com/

                  1 Reply Last reply Reply Quote 0
                  • PixeroP Offline
                    Pixero
                    last edited by

                    😳

                    But the code was so useful I couldn't help myself wanting it to work on more types of objects...

                    ...what if I say: please?

                    1 Reply Last reply Reply Quote 0
                    • JQLJ Offline
                      JQL
                      last edited by

                      I see a lot of possibilities here.

                      Fake beveling at render time?

                      Please Sam?

                      www.casca.pt
                      Visit us on facebook!

                      1 Reply Last reply Reply Quote 0
                      • sdmitchS Offline
                        sdmitch
                        last edited by

                        @jql said:

                        I see a lot of possibilities here.

                        Fake beveling at render time?

                        Please Sam?

                        Sorry guys but I see no possibilities. In fact it is impossible. Why, because the 'offsets' only work if all the angles at a 'corner' are the same. Plus, what do you with 'concave' angled corners?

                        Nothing is worthless, it can always be used as a bad example.

                        http://sdmitch.blogspot.com/

                        1 Reply Last reply Reply Quote 0
                        • PixeroP Offline
                          Pixero
                          last edited by

                          In Thomthom's EdgeTools there is a script for manually diving faces called "Divide Face".
                          It have some clever ways of getting the "splitting edge" to match the face's surrounding edges.
                          Maybe if you took a look at how he does it there it might be possible to implement into your code?

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

                            Guys,

                            This is what Roundcorner does in the first place. So doable, but the code is not exactly concise and straightforward to catch all topological situations, especially those where the offset line don't meet at corner edges, as highlighted by sdmitch (just take an elongated pyramide for instance). Not mentioning concave corners and other complex geometry...

                            Fredo

                            1 Reply Last reply Reply Quote 0
                            • PixeroP Offline
                              Pixero
                              last edited by

                              @fredo:

                              So, when will your new version with all quad face corners be ready?
                              I believe you posted a sneak peak some time ago.

                              1 Reply Last reply Reply Quote 0
                              • JQLJ Offline
                                JQL
                                last edited by

                                That's a pity, but thanks fo the explanation. When rendering an architectural subject bevels make a lot of difference in image results and realism. However when working they are too cumbersome and when sending to Layout or CAD to document the building and dimension it, they become even moreof a nuisance.

                                Having some kind of temporary bevelling that you could toggle, loke subd, would solve the issue.

                                I guess a lot of us would find that an incredible tool and I thought, for a moment, it would be possible...

                                Even so,thanks for your time gentlemen!

                                www.casca.pt
                                Visit us on facebook!

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

                                  Hi guys

                                  This is what I came up with a few months ago, but it fails when curves or inner loops exist.

                                  Also it uses the offset.rb from Smustard(TM).
                                  By using this combination of soft and smooth you are able to put correct dimensions in both SKP and LO
                                  If you need to get rid of the changes the plugin Fix101 takes care of it.

                                  Any ideas to improve this?

                                  #CSR create soften edges for renders
                                  ss = Sketchup.active_model.selection
                                  Sketchup.active_model.start_operation("test")
                                  old_edges = []
                                  new_faces = []
                                  ss.each{|e|old_edges.push e if e.class == Sketchup::Edge}
                                  ss.each{|s|new_faces.push s.offset(-0.0625) if s.class == Sketchup::Face}
                                  old_edges.each{|oe| oe.smooth = true}
                                  new_faces.each{|nf| nf.edges.each{|nfe| nfe.soft = true; nfe.hidden = true}}
                                  Sketchup.active_model.commit_operation

                                  2017.08.07-Screenshot_CSR-0919_01.png
                                  2017.08.07-Screenshot_CSR-0919_02.png
                                  2017.08.07-Screenshot_CSR-0921_01.png

                                  1 Reply Last reply Reply Quote 0
                                  • PixeroP Offline
                                    Pixero
                                    last edited by

                                    @cesaro36:

                                    After adding offset.rb it worked.
                                    However the old edges are hard and the new ones are soft.

                                    1 Reply Last reply Reply Quote 0
                                    • JQLJ Offline
                                      JQL
                                      last edited by

                                      Can anyone convert it to a plugin?

                                      www.casca.pt
                                      Visit us on facebook!

                                      1 Reply Last reply Reply Quote 0
                                      • PixeroP Offline
                                        Pixero
                                        last edited by

                                        I'm trying...

                                        I think it would work better if it only operated on edges that are hard.
                                        How would one do that?

                                        1 Reply Last reply Reply Quote 0
                                        • JQLJ Offline
                                          JQL
                                          last edited by

                                          And do you think it could have a method for operating at render time or is it too slow for that?

                                          Like tag some objects and apply the effect when hitting Thea's render button and then undo it (using skatter's method)?

                                          www.casca.pt
                                          Visit us on facebook!

                                          1 Reply Last reply Reply Quote 0
                                          • PixeroP Offline
                                            Pixero
                                            last edited by

                                            I don't know yet.
                                            It has some bugs as it's not working correctly on for example a cylinder with soft edges. And some other things that would need solving first.

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

                                            Advertisement