• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ 30% Off | Artisan 2 on sale until April 30th Buy Now

[Plugin] FaceSplit v1.0.3

Scheduled Pinned Locked Moved Plugins
44 Posts 18 Posters 28.4k 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.
  • R Offline
    renderiza
    last edited by renderiza 19 Oct 2013, 18:18

    [pre:zunpmadi]Authors:: Anar | Dan Rathbun | Pilou | Renderiza | TIG
    Plugin Name:: FaceSplit
    Version:: 1.0.3
    Date:: 11/4/2013
    Cost:: Free[/pre:zunpmadi]
    FaceSplit

    %(#909090)[Split faces up a variety of ways. This only works as expected on convex faces.

    For plugin compatibility it is recommended to instal] Internet Explorer 9 or higher.

    http://s11.postimg.org/utsik66sz/Face_Split215.png

    Available at
    sketchUcation
    pluginStore
    click here

    ______________________________________________________________________

    Web-Dialog

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

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

    1 Reply Last reply Reply Quote 0
    • C Offline
      cotty
      last edited by 19 Oct 2013, 20:46

      Discussion which leads to this nice plugin...

      Nice! Thank you. πŸ‘

      my SketchUp gallery

      1 Reply Last reply Reply Quote 0
      • R Offline
        renderiza
        last edited by 19 Oct 2013, 23:25

        Thank you for giving a link to the Discussion that started it all. Also here is another that played a big part in optimizing the code.

        Apart from dividing the face like in the second row of the image, was thinking to add additional options like the ones below that. The trick here is to provide an easy to understand user interface where you can change the options.

        http://s24.postimg.org/pqyn23cv9/plans.png

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

        1 Reply Last reply Reply Quote 0
        • M Offline
          mitcorb
          last edited by 20 Oct 2013, 03:54

          Something like: split by angles to centroid, split by medians to centroid, split by angles to medians, split by angles, medians through centroid?
          Or, split by bisect angles, bisect edges, ??

          I take the slow, deliberate approach in my aimless wandering.

          1 Reply Last reply Reply Quote 0
          • R Offline
            renderiza
            last edited by 20 Oct 2013, 04:36

            @mitcorb said:

            Something like: split by angles to centroid, split by medians to centroid, split by angles to medians, split by angles, medians through centroid?

            Correct! πŸ‘

            @mitcorb said:

            Or, split by bisect angles, bisect edges, ??

            Was not thinking of this option but, if I am not mistaken TIG's TriangulateAllFaces is accomplished this way.

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

            1 Reply Last reply Reply Quote 0
            • G Offline
              glro
              last edited by 20 Oct 2013, 12:36

              The purpose of such a plugin may be purely graphical, and all the options mentioned are interesting

              There is another purpose possible
              http://www.spatial.com/products/3d-mesh

              "3D Mesh provides automatic mesh generation for curves, surfaces (triangle and quadrilateral) and volumes (tetrahedral)"

              sketchup is not a real 3d software, since a volume is only a space closed by surfaces

              Would it be possible to write a plugin that would do something similar to what 3d mesh does, by drawing lines on the surfaces and between the surfaces

              3d mesh may follow different patterns
              http://www.ansys.stuba.sk/html/guide_55/g-mod/GMOD7.htm

              This mesh could be exported to a structural analysis software

              Might be related to Voxelize
              http://sketchucation.com/forums/viewtopic.php?t=36063

              a lot of work, though...

              1 Reply Last reply Reply Quote 0
              • I Offline
                iichiversii
                last edited by 20 Oct 2013, 14:15

                excellent, ill be using that πŸ˜„
                Thanks for sharing πŸ‘

                Bring on the Rain...

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tomot
                  last edited by 20 Oct 2013, 19:01

                  very nice! πŸ‘
                  I was thinking of an added option also: We now have split from vertex, can we add split from midpoint?

                  [my plugins](http://thingsvirtual.blogspot.ca/)
                  tomot

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    renderiza
                    last edited by 20 Oct 2013, 21:15

                    Warning!
                    The examples shown below are not features the current version support. These are ideas for possible future updates so please don't be confused by it. πŸ˜‰

                    From vertices to centeroid (Current function of plugin)

                    Currently the plugin has no problem when dealing with multiple faces because the existing edges are no sliced. We only add new vertex in center of geometry and reuse the existing face vertices after that.

                    From medians to centeroid

                    In this case we do split the existing edges in half and that cause effect we see in the 3rd row of the image. Each face will exponentially increase the number of edges in which the script will divide causing different results each time.

                    The example in the 2nd row of the image was able to maintain the same amount of edges per face because each color represent a group. Notice none of the same color groups can touch each other.

                    http://s9.postimg.org/4w3s8mc9r/post.png

                    Conclusion
                    Will have to figure out a way to reproduce the results in the 2nd row of image without having to make multiple groups. Not sure how at the moment but maybe if I open this to discussion in the development forum it can get solved quickly.

                    When I saw the results on row number 3 of image I sort of like what I saw. Maybe this effect is what someone might want who knows. πŸ˜•


                    glro: That would be ideal for the plugin to reach to that level but first I need to figure out simple stuff like the ones mentioned above. Thanks for your input really appreciate it! πŸ‘

                    iichiversii: Hey long time no see!!! Glad you found a use for it. πŸ‘

                    tomot: Yes above I tried demonstrated some of the issues to solve before adding the feature of splitting from medians to centroid.

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

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 20 Oct 2013, 21:30

                      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
                      • R Offline
                        renderiza
                        last edited by 21 Oct 2013, 02:09

                        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
                        • R Offline
                          renderiza
                          last edited by 21 Oct 2013, 02:16

                          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
                          • T Offline
                            TIG Moderator
                            last edited by 21 Oct 2013, 09:16

                            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 21 Oct 2013, 09:19

                              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 21 Oct 2013, 09:44

                                @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 21 Oct 2013, 11:59

                                  @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 21 Oct 2013, 16:05

                                    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 21 Oct 2013, 16:16

                                      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
                                      • R Offline
                                        renderiza
                                        last edited by 21 Oct 2013, 17:10

                                        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 21 Oct 2013, 19:16

                                          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
                                          • 1
                                          • 2
                                          • 3
                                          • 1 / 3
                                          1 / 3
                                          • First post
                                            4/44
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement