• Login
sketchucation logo sketchucation
  • Login
🤑 30% Off | Artisan 2 on sale until April 30th Buy Now

Random move components?

Scheduled Pinned Locked Moved Plugins
8 Posts 6 Posters 2.3k 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.
  • P Offline
    Pherim
    last edited by 25 May 2011, 19:39

    Is there a plugin which can move components (or groups) randomly in a given direction? I have a lot of components in a model which I like to move slightly up or down, but each of them differently far (or at least with great diversion). So if there is something like that or something similar with which I can achieve this goal without having to position them all manually, please tell me. If not, maybe someone can make a plugin which can do this? I imagine being able to give a range in which the object shall be moved (for example between 0 and 1m, also allowing negative values for reverse movement) and then specify the axis on which this movement shall happen. It is not important for my project but maybe it would be possible to choose even two or all three axes, in which case the object would be placed somewhere within a specific 2- or 3-dimensional aream, depending on the distance values. I think it might be useful to have something like that in certain occasions.

    1 Reply Last reply Reply Quote 0
    • S Offline
      snoyes
      last edited by 26 Sept 2012, 01:33

      I needed something similar, so I threw together this one-liner. First ruby code I've ever written, so I'm sure it's possible to make it more elegant.

      Sketchup.active_model.selection.each do |block| block.transform!(Geom;;Transformation.translation(Geom;;Vector3d.new(0,0,3*rand(6)))) end
      

      As written, it takes each component in the selection, and moves it a random multiple of 3 between 0 and 18 along the Z axis.

      1 Reply Last reply Reply Quote 0
      • R Offline
        renderiza
        last edited by 28 Sept 2012, 22:55

        Hi thanks for the code sniped 👍

        I learned how to ask for a random coordinate.

        I am kind of using a variation of this but with the method “move!” for a game I am trying to make. Here is the thread… http://forums.sketchucation.com/viewtopic.php?f=180&t=48043

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

        1 Reply Last reply Reply Quote 0
        • P Offline
          pilou
          last edited by 28 Sept 2012, 23:26

          Scale and rotate Multiple by Chris Fullmer ?

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

          1 Reply Last reply Reply Quote 0
          • E Offline
            eram
            last edited by 23 Mar 2016, 17:16

            This little code (slightly changed for my purpose) worked nicely for me, thanks a lot !

            But to go a step further ... does anybody know how to randomly rotate elements in a similar way ? i've tried a Geom::Transformation.rotation but as it's my first try in ruby, i've no idea of whats going wrong 😄

            1 Reply Last reply Reply Quote 0
            • S Offline
              snoyes
              last edited by 11 Oct 2016, 19:08

              @eram said:

              does anybody know how to randomly rotate elements in a similar way ?

              Rotation requires a point, a vector, and an angle. The point + vector tells us the axis of rotation. Do you want to rotate objects around the origin? Around their "center"? (Which center? Orthocenter? Center of gravity? Something else?) Do you want to rotate just around the Z axis (like spinning a top) or some other random axis (like rolling a bowling ball with side spin)?

              This will get you rotation around the Z access at the origin by a random angle:

              Sketchup.active_model.selection.each do |block| block.transform!(Geom::Transformation.rotation(Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0,0,1), rand(2*Math::PI))) end

              1 Reply Last reply Reply Quote 0
              • E Offline
                Einstein
                last edited by 2 Jan 2018, 21:34

                Hi!
                I applied the script by Snoyes but it certainly creates an undo stack - quite big when I randomly move lots of entities. I know that ThomThom once wrote an article about keeping undo stack clean:

                Link Preview Image
                SketchUp Extensions UX: Don’t break Undo!

                Creating a 3d model isn’t a linear experience, you often have to take a step back, or two or ten. However, while extensions adds great power to SketchUp and let the user create better models,…

                favicon

                Procrastinators Revolt! (www.thomthom.net)

                but I don't know how to apply it to a certain operation. How would this script look with ThomThom's improvement?

                By the way, this could be a plugin request. I didn't find any plugin, neither free nor commercial, to randomly move a bunch of entities. E.g. you choose minimum and maximum move and axes to move along.

                1 Reply Last reply Reply Quote 0
                • E Offline
                  Einstein
                  last edited by 18 Jan 2018, 18:41

                  Ok, I resolved that by myself. I should have used Ruby Code Editor instead of Ruby Console.

                  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