sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Plugin] FaceSplit v1.0.3

    Scheduled Pinned Locked Moved Plugins
    44 Posts 18 Posters 28.4k Views 18 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      No need to group ?
      Collect all of the faces.
      Then collect points for each of the faces - i.e. the 'center' point and the all of the perimeter points needed.
      Iterate the points collection - get the 'center' point, then add the new edges from the other points...

      ### pseudo-code...
      faces=[face1, face2, etc]
      points=[[face1_points_array], [face2_points_array], etc]
      ### NOW add edges from each fixed set of points
      points.each{|pts|
        cpt=pts.shift ### gets/removes 1st point
        pts.each{|pt| ents.add_line(cpt, pt) }
      }
      

      TIG

      1 Reply Last reply Reply Quote 0
      • renderizaR Offline
        renderiza
        last edited by

        Look what happens if you test the code above with object similar to the one in image below. If the face has a hole in the middle and is not triangulated or quadrangular like in the 2nd row the result can be messy.

        The second row show much better result because the first object had quad face before applying script.

        http://s13.postimg.org/8fngx1p3b/solved_1.png

        Hope this helps.

        [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

        1 Reply Last reply Reply Quote 0
        • renderizaR Offline
          renderiza
          last edited by

          Thank you TIG will try that ASAP!!!

          ...TIG's suggestion works! Here is a code sample that you can copy & paste for testing...

          The only function the code does is to split faces from medians to centroid.

          def csplit()
          			
          model = Sketchup.active_model
          ents = model.active_entities
          sel = model.selection
          faces = sel.grep(Sketchup;;Face)
          edges = []
          avg = []
          cl = []
          
          model.start_operation('csplit')
          
          	faces.each do |face|
          		edges << face.edges
          		###########
          		# Medians #
          		###########
          		lines = face.edges
          		lines.each {|e| 
          		e1 = e.start.position
          		e2 = e.end.position  
          		x = (e2.x + e1.x) / 2
          		y = (e2.y + e1.y) / 2
          		z = (e2.z + e1.z) / 2
          		cl << Geom;;Point3d.new( x, y, z )
          		}
          		############
          		# Centroid #
          		############
          		sum = Geom;;Point3d.new(0,0,0)
          		verts = face.vertices
          		n = verts.size.to_f
          		verts.each {|v| sum += ORIGIN.vector_to(v.position) }
          		avg << Geom;;Point3d.new( sum.x/n, sum.y/n, sum.z/n ) #/
          	end # each face
          
          	############################
          	# From Centroid to Medians #
          	############################
          	faces.each do |face|
          		centroid = avg.shift			
          		edges.shift.each {|e| 
          			lc = cl.shift
          			ents.add_line( centroid, lc ) 
          		}
          	end
          
          model.commit_operation
          
          rescue => e
          
          puts "Error <#{e.class.name}; #{e.message} >"
          puts e.backtrace if $VERBOSE
          
          model.abort_operation
          
          else # when no errors;
          
          sel.clear
          
          end # csplit()
          
          #######
          # Run #
          #######
          csplit()
          
          
          

          Always welcome suggestion to make code better...cheers! 👍

          [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

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

            I was about to tell you of the issue with faces with holes or L shapes having a centroid 'off-face', but you have displayed it already...
            Here is the 'fix'...
            As you iterate each face check
            face.classify point(cpt)
            If it is not on the face, on a face-edge or on a face-vertex then do this:
            tr=Geom::Transformation.new() es=ents.intersect_with(false, tr, ents, tr, true, ents.to_a)
            You could reduce the intersected array to say face.edges provided you have a reference to the face ?
            Then if some edges collected into 'es' remain 'unfaced' use this to erase them? :
            es.grep(Sketchup::Edge).each{|e|e.erase! unless e.faces[0]}

            😕

            TIG

            1 Reply Last reply Reply Quote 0
            • pilouP Offline
              pilou
              last edited by

              Bravo! 😎
              Some testings in view and some track the bugs! 😉

              Ps you are very friendly to have put my name but take attention that I have not made any code just a little moment of inspiration (given by a French guy anar! 😉 ☀

              Frenchy Pilou
              Is beautiful that please without concept!
              My Little site :)

              1 Reply Last reply Reply Quote 0
              • A Offline
                anar
                last edited by

                @unknownuser said:

                Bravo! 😎
                Some testings in view and some track the bugs! 😉

                Ps you are very friendly to have put my name but take attention that I have not made any code just a little moment of inspiration (given by a French guy anar! 😉 ☀

                Thanks Pilou for mentioning that I started that discussion with you here : http://www.polyloop.net/showthread.php/9854-Topmod-De-la-maille-topologique%21/page7#133

                And thanks also because without you that plugin would have never been made !

                Anar
                http://www.reppersdelight.spacymen.com

                1 Reply Last reply Reply Quote 0
                • G Offline
                  glro
                  last edited by

                  @renderiza said:

                  Look what happens if you test the code above with object similar to the one in image below. If the face has a hole in the middle and is not triangulated or quadrangular like in the 2nd row the result can be messy.

                  The second row show much better result because the first object had quad face before applying script.

                  http://s13.postimg.org/8fngx1p3b/solved_1.png

                  Hope this helps.

                  i thought it was only for surfaces, but i see that it works on volumes also...

                  would it be possible to split the volume following the liness making like a 3d puzzle?

                  this would mean adding surfaces following the lines to make independant volumes

                  like "voxelize.rb", but not only cubes

                  1 Reply Last reply Reply Quote 0
                  • pilouP Offline
                    pilou
                    last edited by

                    Seems working fine 😄


                    faceclip.jpg

                    Frenchy Pilou
                    Is beautiful that please without concept!
                    My Little site :)

                    1 Reply Last reply Reply Quote 0
                    • pilouP Offline
                      pilou
                      last edited by

                      And all medians are present! 👍
                      I don't want imagine the possibilities in 3D! 💚

                      faceclip1.jpg

                      Frenchy Pilou
                      Is beautiful that please without concept!
                      My Little site :)

                      1 Reply Last reply Reply Quote 0
                      • renderizaR Offline
                        renderiza
                        last edited by

                        TIG: Thank you TIG will test that out effective immediately! 🎉

                        Pilou & Anar: People that bring ideas to the table deserve recognition as well. 👍

                        glro: That would be very cool indeed! I think there is a plugin that does something like this but don't remember it just now. If I find it will let you know. 👍

                        Pilou: Very cool! 👍

                        [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

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

                          Hi!

                          May I suggest an addition.
                          For people working in 3ds Max a imported SketchUp model is sometimes hard to work with because it doesn't consist of evenly sized quad faces. I have this idea to be able to split a face with inner loops like windows by projecting lines in the direction of the edges to the outer loop.
                          See this quick sketch.
                          image.jpg

                          1 Reply Last reply Reply Quote 0
                          • G Offline
                            glro
                            last edited by

                            @renderiza said:

                            ..
                            [b]glro:
                            That would be very cool indeed! I think there is a plugin that does something like this but don't remember it just now. If I find it will let you know. 👍

                            :

                            Maybe you think also to voxelize.rb
                            http://sketchucation.com/forums/viewtopic.php?t=36063

                            but voxelize makes cubes only; it would be funny to split the volume in exact sub-volumes, and try to build the whole volume back again, using sketchup

                            i have a 3d connexion mouse, and there is a game like this, to learn how to use it

                            and in addition, splitting a volume in sub-volumes is equivalent to building a 3d mesh, for structural analysis...

                            1 Reply Last reply Reply Quote 0
                            • renderizaR Offline
                              renderiza
                              last edited by

                              @pixero said:

                              I have this idea to be able to split a face with inner loops like windows by projecting lines in the direction of the edges to the outer loop.

                              This is excellent idea! It will produce the cleanest geometry possible before dividing it even more. 👍

                              @glro said:

                              Maybe you think also to voxelize.rb
                              http://sketchucation.com/forums/viewtopic.php?t=36063

                              but voxelize makes cubes only; it would be funny to split the volume in exact sub-volumes, and try to build the whole volume back again, using sketchup

                              i have a 3d connexion mouse, and there is a game like this, to learn how to use it

                              and in addition, splitting a volume in sub-volumes is equivalent to building a 3d mesh, for structural analysis...

                              The plugin I had in my mind was not voxelize...it was one that only worked if you had SketchUp Pro.

                              Anyways making a plugin like this would be cool indeed. Not sure if I possess the knowledge to do it myself at the moment but will see if I can experiment with the idea in the future.

                              [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                              1 Reply Last reply Reply Quote 0
                              • renderizaR Offline
                                renderiza
                                last edited by

                                [pre:3p20mm78]Authors:: Anar | Dan Rathbun | Pilou | Renderiza | TIG
                                Plugin Name:: FaceSplit
                                Version:: 1.0.1
                                Date:: 10/28/2013
                                Cost:: Free[/pre:3p20mm78]
                                FaceSplit v1.0.1 is now available for download.

                                http://s18.postimg.org/6mnop92dl/split_dlg.png

                                Note: Will eventually make video explaining how to use plugin.

                                [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                                1 Reply Last reply Reply Quote 0
                                • pilouP Offline
                                  pilou
                                  last edited by

                                  Sure a video will give some ideas to users! 😄

                                  What are the natures of the up date ?

                                  diamond.jpg

                                  http://sketchucation.com/forums/download/file.php?id=111403

                                  Frenchy Pilou
                                  Is beautiful that please without concept!
                                  My Little site :)

                                  1 Reply Last reply Reply Quote 0
                                  • guanjinG Offline
                                    guanjin
                                    last edited by

                                    我点击图标,没有任何反应!

                                    I come from China, is to learn

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

                                      @guanjin said:

                                      我点击图标,没有任何反应!

                                      You should click after you have selected one or more faces.

                                      my SketchUp gallery

                                      1 Reply Last reply Reply Quote 0
                                      • guanjinG Offline
                                        guanjin
                                        last edited by

                                        @cotty said:

                                        @guanjin said:

                                        我点击图标,没有任何反应!

                                        You should click after you have selected one or more faces.

                                        999999999999999999.gif

                                        😒
                                        I have tried。
                                        Thank you

                                        I come from China, is to learn

                                        1 Reply Last reply Reply Quote 0
                                        • 1 Offline
                                          120711014
                                          last edited by

                                          thanks for sharing~~~~~~~~

                                          1 Reply Last reply Reply Quote 0
                                          • U Offline
                                            Ulimann
                                            last edited by

                                            I have tried but no success,to get this plugin to work.I have reinstalled a few times!
                                            Running SU 8 Pro on Windows 7.
                                            Any suggestion to get it working?

                                            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