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

    Adding geometry to model - speed issues

    Scheduled Pinned Locked Moved Developers' Forum
    40 Posts 7 Posters 5.4k 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.
    • J Offline
      Jim
      last edited by

      @tig said:

      GC.start is Jim's baby - built-in - As I understand it you start if before making the groups ?

      I thought I learned of it on this forum!

      I don't think it's the GC that's slowing adding geometry - more likely it is Sketchup looking to make faces and break overlapping geometry as geometry is either added or exploded. (pure conjecture.)

      Hi

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

        I don't think I've tested this on SU7 but on SU6, using the add_faces_from_mesh method was way faster than adding individual faces using the add_face method. I thought it was 3-4 times faster (but I don't remember for sure). Maybe they have tightened the gap between these method in SU7.1?

        For a quick test, just use SDS. Normal operation using the add_faces_from_mesh method, but if you choose the 'copy materials' option, it uses the add_face method.

        SketchUp Plugins for Professionals

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          @jim said:

          I don't think it's the GC that's slowing adding geometry - more likely it is Sketchup looking to make faces and break overlapping geometry as geometry is either added or exploded. (pure conjecture.)

          That's what I was suspecting as well. Was hoping for different result with PolygonMesh - that's it's simple be inserted as-is. But seeing that we don't actually know what it is... ...just guessing. πŸ˜•

          But I take it there's no tricks hidden up in any sleeves?

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @whaat said:

            I don't think I've tested this on SU7 but on SU6, using the add_faces_from_mesh method was way faster than adding individual faces using the add_face method. I thought it was 3-4 times faster (but I don't remember for sure). Maybe they have tightened the gap between these method in SU7.1?

            For a quick test, just use SDS. Normal operation using the add_faces_from_mesh method, but if you choose the 'copy materials' option, it uses the add_face method.

            Yes - I find add_faces_from_mesh to be faster than add_face to be faster as well. But comparing the number of polygons in the mesh with the time it takes to add the geometry - time does not increase linearly. It does seem that the time relates to the number of entities already in the context you add to.

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • AdamBA Offline
              AdamB
              last edited by

              @jim said:

              @tig said:

              GC.start is Jim's baby - built-in - As I understand it you start if before making the groups ?

              I thought I learned of it on this forum!

              I don't think it's the GC that's slowing adding geometry - more likely it is Sketchup looking to make faces and break overlapping geometry as geometry is either added or exploded. (pure conjecture.)

              Try this:

              ` def addfaces(ents = Sketchup.active_model.entities)

              vertices = [Geom::Point3d.new(0,0,0), Geom::Point3d.new(1,0,0),Geom::Point3d.new(0,1,0)]
              
              start = Time.new
              1000.times do
              	ents.add_face vertices	
              end
              puts "Same tris took #{(Time.new - start)}"
              
              start = Time.new
              1000.times do
              	ents.add_face vertices
              	vertices[0].z += 0.1
              	vertices[1].z += 0.1
              	vertices[2].z += 0.1
              end
              puts "different tris took #{(Time.new - start)}"
              
              
              start = Time.new
              1000.times do
              	ents.add_face vertices
              	vertices[0].z += 0.1
              	vertices[1].z += 0.1
              	vertices[2].z += 0.1
              end
              puts "more different tris took #{(Time.new - start)}"
              

              end

              addfaces`

              Firstly adds 1000 triangles using the same coordinates, secondly adds 1000 triangles with unique vertices, lastly adds another 1000 triangles with unique vertices. Shows a 10x difference in performance, yet the geometry engine will be constructing the topology in all cases - ie doing work.

              This would seem to indicate its an insertion bottleneck - which is consistent with thomthom findings.

              What does it mean? It means its a brick wall and adding geometry in SU is slow and there is nothing you can do about it.

              Developer of LightUp Click for website

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @adamb said:

                What does it mean? It means its a brick wall and adding geometry in SU is slow and there is nothing you can do about it.

                😞

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  I ran that script four times:

                  ` addfaces
                  Same tris took 0.05
                  different tris took 0.71
                  more different tris took 1.9
                  nil

                  addfaces
                  Same tris took 1.84
                  different tris took 1.68
                  more different tris took 1.87
                  nil

                  addfaces
                  Same tris took 1.85
                  different tris took 1.659
                  more different tris took 1.89
                  nil

                  addfaces
                  Same tris took 1.85
                  different tris took 1.69
                  more different tris took 1.86
                  nil`

                  Didn't delete geometry in between.

                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    Moved the geometry slightly away from original position and ran three more tests:

                    ` addfaces
                    Same tris took 1.8
                    different tris took 2.64
                    more different tris took 4.13
                    nil

                    addfaces
                    Same tris took 3.62
                    different tris took 3.26
                    more different tris took 3.65
                    nil

                    addfaces
                    Same tris took 3.62
                    different tris took 3.26
                    more different tris took 3.68
                    nil`

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

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

                      How about entities.fill_from_mesh(...) rather than add_faces_from_mesh(..)
                      http://code.google.com/apis/sketchup/docs/ourdoc/entities.html#fill_from_mesh
                      is that quicker ?

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        I had a mad hope that Sketchup.break_edges = false might change something...

                        ` Sketchup.break_edges=false
                        false

                        addfaces
                        Same tris took 3.58
                        different tris took 5.62
                        more different tris took 7.56
                        nil

                        Sketchup.break_edges=true
                        true`

                        nope!

                        @tig said:

                        How about entities.fill_from_mesh(...) rather than add_faces_from_mesh(..)
                        http://code.google.com/apis/sketchup/docs/ourdoc/entities.html#fill_from_mesh
                        is that quicker ?

                        oooh. I've missed that method. Will give it a wirl when I get home. That even has a number of features which saves me some work when it comes to smooth vs faceted. πŸ‘

                        Thomas Thomassen β€” SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          Jim
                          last edited by

                          @whaat said:

                          I wasn't aware of this method! Has it really been available since SU6??

                          Me either. I thought I knew the API up and down (I act like, sometimes!) Makes me wonder what else is in there.

                          edit - maybe it was always "there", just not documented until the new automatic document system started?

                          Hi

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

                            @tig said:

                            How about entities.fill_from_mesh(...) rather than add_faces_from_mesh(..)
                            http://code.google.com/apis/sketchup/docs/ourdoc/entities.html#fill_from_mesh
                            is that quicker ?

                            I wasn't aware of this method! Has it really been available since SU6??
                            Someone, please do a performance test of this method now! (I would if I could.... 😞 )

                            SketchUp Plugins for Professionals

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              @whaat said:

                              @tig said:

                              How about entities.fill_from_mesh(...) rather than add_faces_from_mesh(..)
                              http://code.google.com/apis/sketchup/docs/ourdoc/entities.html#fill_from_mesh
                              is that quicker ?

                              I wasn't aware of this method! Has it really been available since SU6??
                              Someone, please do a performance test of this method now! (I would if I could.... 😞 )

                              I tried it in SU6 - it's there al'right. I will try in SU5 later today.

                              I think I've overlooked it because I've never used PolygonMeshes before.

                              Thomas Thomassen β€” SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by

                                The old documentation doesn't seem to mention it: http://download.sketchup.com/OnlineDoc/gsu6_ruby/Docs/ruby-entities.html

                                Maybe it was added in the November update of the docs.

                                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                List of my plugins and link to the CookieWare fund

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

                                  @thomthom said:

                                  The old documentation doesn't seem to mention it: http://download.sketchup.com/OnlineDoc/gsu6_ruby/Docs/ruby-entities.html

                                  Maybe it was added in the November update of the docs.

                                  Sometimes I just want to slap whoever was responsible for the API docs...however, right now, I want to kick them in the junk.

                                  SketchUp Plugins for Professionals

                                  1 Reply Last reply Reply Quote 0
                                  • thomthomT Offline
                                    thomthom
                                    last edited by

                                    Come to think of it - I do remember reading somewhere about PolygonMesh'es being added without error control and being somewhat quicker. But since I previously had no interests in PolygonMeshes I didn't pay much attention. Assumed there was only one method to add a mesh.

                                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                    List of my plugins and link to the CookieWare fund

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

                                      fill_from_mesh exists in SU5 as well.

                                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • thomthomT Offline
                                        thomthom
                                        last edited by

                                        fill_from_mesh seems to be twice as fast as add_faces_from_mesh.
                                        But its default values doesn't match with the manual. The manual claims that the default for smooth is 0. But when I omit that value I get a soft and smooth mesh. I have to explicitly set it to 0 for no smoothing.

                                        And I can't make out what the weld vertices do. I don't see any difference in what it produces.

                                        Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                        List of my plugins and link to the CookieWare fund

                                        1 Reply Last reply Reply Quote 0
                                        • thomthomT Offline
                                          thomthom
                                          last edited by

                                          I might have been a bit quick to judge the speed difference...

                                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                          List of my plugins and link to the CookieWare fund

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

                                            @thomthom said:

                                            And I can't make out what the weld vertices do. I don't see any difference in what it produces.

                                            Any performance increase when welding vertices?

                                            SketchUp Plugins for Professionals

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

                                            Advertisement