sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Adding geometry to model - speed issues

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

                  hm.. haven't tried too much with that right now. But I'm profiling a plugins right now. Might touch upon it later.

                  add_faces_from_mesh(polygonmesh)
                  ` TT_Teapot.create_teapot(16)

                  Mesh generated in 11.35 seconds
                  Teapot with 16 segments generated in 13.201 seconds
                  #Sketchup::Group:0xe9c9268`

                  fill_from_mesh(polygonmesh)
                  ` TT_Teapot.create_teapot(16)

                  Mesh generated in 0.157 seconds
                  Teapot with 16 segments generated in 2.02 seconds
                  #Sketchup::Group:0xe792a48`

                  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 find no noticeable difference in speed when I change smoothing and/or welding.
                    And I still have no idea what welding vs not welding really do.

                    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

                      polygonmesh.point_index(point) is slow

                      Found it faster to build a separate Hash to keep track of it as I added the points for the mesh.

                      While adding points
                      point_index = {} p.each { |i| point_index[i] = pm.add_point(i) }

                      When collecting points to build polygon:
                      indexes = points.collect { |point| point_index[point] }

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

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        toxicvoxel
                        last edited by

                        I ran into the speed issue with realy large models and opted to write the geometry definition to a file format and then importing via a script - which gave me faster results, - but this may not suit your needs.

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

                          I guess that 'welding' ensures that a vertex that shares a common position with another vertex is combined [welded] into just one vertex and you don't get the weirdness of two triangular faces leaking into each other as their actually common-vertex is taken as two separate vertices ?

                          The API is so rubbish on this that it could mean anything... but ifI had designed this Method that's what it'd do ! πŸ’­

                          TIG

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

                            That's what I expected before I tested it. I thought each polygon would become a separated disconnected entity. But everything seems to merge regardless. The PolygonMesh class is a peculiar one.

                            But that fill method really helped me TIG. Thanks for pointing that one out! πŸ‘

                            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

                              I suspect that each triangular mesh is actually made as a separate shape BUT since the vertices and edges merge as the mesh is completed with more triangles they too disappear and the mesh 'meshes'... however, perhaps with very small [or large] dimensions perhaps the triangles are sufficiently separated and the vertices don't coincide within tolerances and the vertices aren't welded ? So perhaps the welded option takes a little more time but ensures a proper mesh ?

                              Someone went to the trouble to write this method but then decided not to explain what it does too well !!! πŸ˜’

                              TIG

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

                                I hope Mr. Someone comes back and finished the job...

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

                                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