sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [Plugin] RandomPushPull v2.5 20110709

    Scheduled Pinned Locked Moved Plugins
    28 Posts 8 Posters 26.1k Views 8 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

      This version is updated and tidied...
      Range errors now corrected.
      Negative pp values now allowed.
      The max/min now works properly with +/-ve values.
      The selection now passes to the newly pushpulled faces.
      Area comparisons added for 're-selection' [thanks kyyu!']Put into Plugins folder and restart...PayPalButton

      TIG

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

        Thanks for sharing!

        Regards,
        JGA

        1 Reply Last reply Reply Quote 0
        • dereiD Offline
          derei
          last edited by

          There is a "judgement" error in the plugin code. That is why did not respect max/min.

          The original plugin makes push-pull for this distance:

          selection.each{|s|s.pushpull((@ppmax-@ppmin) * rand)}
          

          So, if I input Min(400); Max(600) it will make pushPull for a random value of 200.
          In order to make pushPull for a random value between 400 and 600 i think, the code should look like this:

          selection.each{ |s| s.pushpull(@ppmin + (@ppmax-@ppmin) * rand) }
          

          In this way, you set the minimum value (@ppmin) to pushpull, then add the random value of 200 (up to 600).
          But, as rand method doesn't provide 0 or 1, there will not be pieces equal with 400 or 600.

          DESIGNER AND ARTIST [DEREI.UK](http://derei.uk/l)

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

            @unknownuser said:

            But, as rand method doesn't provide 0 or 1, there will not be pieces equal with 400 or 600.

            rand does return 0

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

            1 Reply Last reply Reply Quote 0
            • dereiD Offline
              derei
              last edited by

              @thomthom said:

              @unknownuser said:

              But, as rand method doesn't provide 0 or 1, there will not be pieces equal with 400 or 600.

              rand does return 0

              I stand corrected πŸ˜„ , but surely it does not return 1, so max value of push-pull will be never returned, right?

              DESIGNER AND ARTIST [DEREI.UK](http://derei.uk/l)

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

                Correct

                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

                  Here's v2.1 http://forums.sketchucation.com/viewtopic.php?p=340452#p340452
                  It now uses the min/max range 'properly'... AND if the random value is actually ==min or ==max then it is used; the accuracy for using the actual max value is set at 1/1000001. On the incredibly rare times it matches exactly or it is exceeded very slightly then 'max' is used, as is 'min' when it's met exactly [rarely].

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • dereiD Offline
                    derei
                    last edited by

                    Maybe you could add option in input box for push-pulling on negative values too, or force positive.

                    EDIT: - i'm not sure (as I'm not a programmer), but this code doesn't pushpull between min and max.

                    mx can have values much less than @ppmin, so pp can have very easy a negative value (if rn=10, mx = @ppmax * 0.0001; so what are the odds that between max and min to be a difference of 4 zeroes? In consequence pp = mx(very small) - @ppmin(highly probable much larger) ==> negative value for pp ).

                    
                    rn=rand(1000001)
                    	  if rn!=0
                    	    mx=@ppmax*(rn/1000000.0)
                    		if mx > @ppmax
                    	      mx=@ppmax
                    	    end
                          else
                    	    mx=0
                    	  end
                    	  pp=mx-@ppmin
                    	  face.pushpull(pp) if pp!=0
                    
                    

                    DESIGNER AND ARTIST [DEREI.UK](http://derei.uk/l)

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

                      Here's v2.2 http://forums.sketchucation.com/viewtopic.php?p=340452#p340452
                      I think I've sorted the range AND allowed negative values too...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • dereiD Offline
                        derei
                        last edited by

                        @tig said:

                        Here's v2.2 http://forums.sketchucation.com/viewtopic.php?p=340452#p340452
                        I think I've sorted the range AND allowed negative values too...

                        πŸ˜• I'm not sure what you are trying to do there, but wouldn't be easier to force the pp value in v.2.1 to .abs? πŸ˜„ And...it still doesn't limit between max/min 😞


                        random1.jpg


                        random2.jpg

                        DESIGNER AND ARTIST [DEREI.UK](http://derei.uk/l)

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

                          Here's v2.3 http://forums.sketchucation.com/viewtopic.php?p=340452#p340452
                          It now works properly between the max/min range and allows +/-ve values... πŸ˜•
                          I hope!

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • dereiD Offline
                            derei
                            last edited by

                            Well, good news! It works like a charm πŸ˜‰
                            Thank you very much!

                            DESIGNER AND ARTIST [DEREI.UK](http://derei.uk/l)

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

                              My brain really hurt with the logic of it... but now it's too obvious πŸ˜’

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • dereiD Offline
                                derei
                                last edited by

                                @tig said:

                                My brain really hurt with the logic of it... but now it's too obvious πŸ˜’

                                My brain hurt too trying to "discover" the reason why you tried such complicated ways to do it. Especially because my programming skills are like the result of rand method (yes, between 0 and almost 1 πŸ˜† ) and I try to learn something from what you do.

                                DESIGNER AND ARTIST [DEREI.UK](http://derei.uk/l)

                                1 Reply Last reply Reply Quote 0
                                • pilouP Offline
                                  pilou
                                  last edited by

                                  So it was a true random result! πŸ’š

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

                                  1 Reply Last reply Reply Quote 0
                                  • pilouP Offline
                                    pilou
                                    last edited by

                                    Always funny and robust! 😎
                                    Randompushpull.jpg

                                    re-apply on result with the all faces (top and lateral) πŸ˜‰
                                    result is not too regular? (I took 1 and .1)

                                    Does it possible to keep the first selection? (top faces)

                                    Randompushpul1.jpg

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

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

                                      Unfortunately when you PushPull a face it disappears - the face that is at the new location isn't the same face - that's been deleted by Sketchup...

                                      So... it's not easy to get a reference to the new face...

                                      BUT you could do it... you know the plane of the picked face, you know its pt0=vertices[0].position, you know the pushpull vector, so you can offset the pt0 and then test for the new faces added since the pushpull was done and find the one with the same/reversed normal, parallel plane and coincident vertex at the offset pt0 location...

                                      BUT I'm not going to code it πŸ˜’

                                      TIG

                                      1 Reply Last reply Reply Quote 0
                                      • pilouP Offline
                                        pilou
                                        last edited by

                                        In this particular case same "top square"
                                        I can use the Selected by aera by Sdmitch πŸ˜‰

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

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

                                          Except there might be faces with the same area that were not the ones you want - so then things like face.normal / plane becomes relevant too - BUT comparing areas IS a good 'outside-of-the-box' test idea πŸ˜‰

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • pilouP Offline
                                            pilou
                                            last edited by

                                            @unknownuser said:

                                            Except there might be faces with the same area that were not the ones you want

                                            As I had started from a sphere and took a minimum measure more large than the big edges on the surface's sphere πŸ€“
                                            that can't be arrived πŸ˜‰
                                            It was a very particular case πŸ˜„

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

                                            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