sketchucation logo sketchucation
    • Login
    ⚠️ Attention | Having issues with Sketchucation Tools 5? Report Here

    Add_edges with a LOT of edges

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 3 Posters 216 Views 3 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

      It may be that the points are so close together that a very tiny edge would result.
      There is a known limitation of tiny edge/facet creation [~0.1mm ?] smaller lines will fail to form.
      If you test for the equivalent of the points as you add them to the array this might avoid the error... Make the array as a Point3d...
      Assuming this happens in an iteration block {} etc...

      point = Geom;;Point3d.new(xOld.to_f.mm, yOld.to_f.mm, zOld.to_f.mm)
      points << point if not point==points[-1]
      

      This ensures that the distance between the two points is sufficient for SketchUp to consider them as not being the same point and thereby greatly improves the chances of a small line actually getting made!

      TIG

      1 Reply Last reply Reply Quote 0
      • N Offline
        niccah
        last edited by

        @tig said:

        There is a known limitation of tiny edge/facet creation [~0.1mm ?] smaller lines will fail to form.

        Oh shit, you are right! That's exactly the problem... all missing lines are smaller than 0.1 mm. The problem is, I have to display these small edges, because I need this "smooth" curvature.

        Puh, is there a possibility to change this limitation of about 0.1 mm?

        Thanks TIG for your fast answer!!!

        1 Reply Last reply Reply Quote 0
        • N Offline
          niccah
          last edited by

          Okay, I found a solution:

          Google Product Forums

          favicon

          (productforums.google.com)

          They said: I have to enlarge the model to 1000x... insert all the points and scale them back after that... What do you think?

          1 Reply Last reply Reply Quote 0
          • N Offline
            niccah
            last edited by

            I tried to scale this points at first...

            ` points << [(xOld.to_f10000).mm, (yOld.to_f10000).mm, (zOld.to_f*10000).mm]

            group = Sketchup.active_model.entities.add_group
            group.entities.add_edges points

            new_transform = Geom::Transformation.scaling 0.0001
            group.transformation = new_transform`

            And, oh my goodness, it works!

            Thanks TIG again for your hints!!!

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

              I very glad you solved your own problem - and shared a solution, so that others might benefit - that's what SCF is about.
              Scaling everything up as you make the points/lines, then scaling down at the end... was going to be my next suggestion - but you got there by yourself!
              πŸ˜„

              TIG

              1 Reply Last reply Reply Quote 0
              • N Offline
                niccah
                last edited by

                I have to push this topic again to the top...

                I would like to present my current code, to import some gCode...

                ` points = Array.new;

                while (...)
                points << [(xOld.to_f1000).mm, (yOld.to_f1000).mm, (zOld.to_f*1000).mm]
                end

                group = entity.entities.add_group
                group.entities.add_edges points

                new_transform = Geom::Transformation.scaling 0.001
                group.transformation = new_transform`

                I'm not realy happy with this method. Sometimes, I have to import 80.000 points and more. So, it takes a loooooooong time, to import this... I tried, to scale just the small points, but it takes exacly the same time...

                Do you have an idea, how I can accelerate this gCode importing?

                Thanks again for all your help!

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

                  You could at least try to read data and process in one go ? ...
                  points=[] IO.readlines(pathtoxyztextfile).each{|line| xyz=line.chomp.split(",") ### assuming file is comma separated data next unless xyz.length==3 ### i.e. [x, y, z] points<<Geom::Point3d.new((xyz[0].to_f*1000).mm, (xyz[1].to_f*1000).mm, (xyz[2].to_f*1000).mm) }
                  then add edges into a new group, from the points, much as your code...
                  group=model.active_entities.add_group() group.entities.add_edges(points)
                  then rescale the group's geometry, NOT the group itself...
                  tr=Geom::Transformation.scaling(0.001) group.entities.transform_entities(tr, group.entities.to_a)

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    niccah
                    last edited by

                    Thanks TIG for your ideas! I tried it several times, to get a statistical result... but there is no time difference between group transforming and entities transforming.

                    However, I think, there is no chance to decrease the calculation time...

                    Thanks a again! I could not improve the code, but I learned again a lot...

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

                      @tig said:

                      then rescale the group's geometry, NOT the group itself...
                      tr=Geom::Transformation.scaling(0.001) group.entities.transform_entities(tr, group.entities.to_a)

                      Then you make the edges smaller than 1mm - if you try to work with that geometry you might summon critters of dark dimensions. πŸ˜•

                      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

                        Yes.... but...
                        Small edges can exist quite happily, it's just using them that is problematical.
                        So if he has completed all changes/processing, then I believe that rescaling the geometry is best, but if further changes are wanted then any [re]scaling needs to be avoided until all processing is done anyway... πŸ˜•

                        TIG

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

                        Advertisement