[Plugin] RandomPushPull v2.5 20110709

[Plugin] RandomPushPull v2.5 20110709

Postby TIG » Thu Jul 07, 2011 12:01 pm

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!']
RandomPushPull.rb
4
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.0 20110707

Postby JGA » Thu Jul 07, 2011 1:23 pm

Thanks for sharing!
1
Regards,
JGA

JGA 
 

Re: [Plugin] RandomPushPull v2.0 20110707

Postby derei » Thu Jul 07, 2011 1:48 pm

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:
Code: Select all
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:
Code: Select all
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.
0
DESIGNER AND ARTIST DEREI.UK
User avatar
derei 
 

Re: [Plugin] RandomPushPull v2.0 20110707

Postby thomthom » Thu Jul 07, 2011 1:52 pm

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

rand does return 0
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] RandomPushPull v2.0 20110707

Postby derei » Thu Jul 07, 2011 1:54 pm

thomthom wrote:
dereeei wrote: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 :D , but surely it does not return 1, so max value of push-pull will be never returned, right?
0
DESIGNER AND ARTIST DEREI.UK
User avatar
derei 
 

Re: [Plugin] RandomPushPull v2.0 20110707

Postby thomthom » Thu Jul 07, 2011 2:06 pm

Correct
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] RandomPushPull v2.1 20110707

Postby TIG » Thu Jul 07, 2011 3:04 pm

Here's v2.1 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].
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.1 20110707

Postby derei » Thu Jul 07, 2011 3:22 pm

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 ).

Code: Select all
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
0
DESIGNER AND ARTIST DEREI.UK
User avatar
derei 
 

Re: [Plugin] RandomPushPull v2.2 20110707

Postby TIG » Thu Jul 07, 2011 3:57 pm

Here's v2.2 viewtopic.php?p=340452#p340452
I think I've sorted the range AND allowed negative values too...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.2 20110707

Postby derei » Thu Jul 07, 2011 4:08 pm

TIG wrote:Here's v2.2 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? :D And...it still doesn't limit between max/min :(
0
DESIGNER AND ARTIST DEREI.UK
User avatar
derei 
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby TIG » Thu Jul 07, 2011 4:28 pm

Here's v2.3 viewtopic.php?p=340452#p340452
It now works properly between the max/min range and allows +/-ve values... :?
I hope!
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby derei » Thu Jul 07, 2011 4:36 pm

Well, good news! It works like a charm ;)
Thank you very much!
0
DESIGNER AND ARTIST DEREI.UK
User avatar
derei 
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby TIG » Thu Jul 07, 2011 4:52 pm

My brain really hurt with the logic of it... but now it's too obvious :roll:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby derei » Thu Jul 07, 2011 4:58 pm

TIG wrote:My brain really hurt with the logic of it... but now it's too obvious :roll:

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 :lol: ) and I try to learn something from what you do.
0
DESIGNER AND ARTIST DEREI.UK
User avatar
derei 
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby pilou » Thu Jul 07, 2011 5:06 pm

So it was a true random result! :mrgreen:
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby pilou » Thu Jul 07, 2011 9:58 pm

Always funny and robust! :fro:
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
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby TIG » Thu Jul 07, 2011 10:17 pm

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 :roll:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby pilou » Thu Jul 07, 2011 10:24 pm

In this particular case same "top square"
I can use the Selected by aera by Sdmitch ;)
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby TIG » Thu Jul 07, 2011 10:31 pm

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 ;)
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.3 20110707

Postby pilou » Thu Jul 07, 2011 10:38 pm

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 :ugeek:
that can't be arrived ;)
It was a very particular case :D
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] RandomPushPull v2.4 20110707

Postby TIG » Thu Jul 07, 2011 11:15 pm

Here's v2.4 viewtopic.php?p=340452#p340452
The selection now passes to the newly pushpulled faces even though the original faces have been deleted by Sketchup...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.4 20110707

Postby pilou » Thu Jul 07, 2011 11:34 pm

Seems selection are not keeping all the initial faces selected! :o
(tryed with some adjacents facets on a thick sphere )

Does exist a Scale multiple ? (for each facets selected)
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] RandomPushPull v2.4 20110707

Postby TIG » Fri Jul 08, 2011 9:28 am

As I explained, the original face is lost with a pushpull so I need to find the equivalent new face... At the moment it matches area, face normal and face plane [offset by the pushpull distance] - even the slightest variance in the figures that Sketchup calculates will result in a mismatch - so I suspect that's why some faces are being ignored :roll:
Any ideas on a better way to spot newly pushpulled faces is invited... :?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.4 20110707

Postby jorge2011 » Fri Jul 08, 2011 3:07 pm

you can add a random move tool?
0

jorge2011 
 

Re: [Plugin] RandomPushPull v2.4 20110707

Postby kyyu » Sat Jul 09, 2011 2:25 am

TIG wrote:As I explained, the original face is lost with a pushpull so I need to find the equivalent new face... At the moment it matches area, face normal and face plane [offset by the pushpull distance] - even the slightest variance in the figures that Sketchup calculates will result in a mismatch - so I suspect that's why some faces are being ignored :roll:
Any ideas on a better way to spot newly pushpulled faces is invited... :?

TIG,

Seems to work 100%, if you account for the tiny area difference of the new face. In line #64, I used "if face.area-e[0].abs < 0.000001" instead of "if face.area==e[0]".

Well, at least this worked on a 7 inch diameter sphere. Don't know if it will fail for other scales.

[Addition]
Ok, I had a chance to check if scaling would make the new area test fail. Looks ok so far. My sphere had 288 faces. Initially 7 inches in diameter. I've scaled it up to 70, 700, and 7000 inch diameter. And even with the larger areas, 0.000001 difference still worked to compare if the faces have the same area. The plugin still kept the selection on all 288 faces, in all the tests.

RandomPushPull (v2.4 sel faces passed,my fix).rb
0

kyyu 
 

Re: [Plugin] RandomPushPull v2.4 20110707

Postby sonnycds » Sat Jul 09, 2011 1:19 pm

Muchas gracias, me viene al pelo :berserk:
0

sonnycds 
 

Re: [Plugin] RandomPushPull v2.5 20110709

Postby TIG » Sat Jul 09, 2011 1:24 pm

Here's v2.5 viewtopic.php?p=340452#p340452
Kyyu beat me to it with an 'area accuracy check', which now [hopefully] ensures that all of the selected faces that are pushpulled [and thereby get erased] now get their selection passed onto the the newly added face every time... :D
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] RandomPushPull v2.5 20110709

Postby pilou » Sat Jul 09, 2011 4:17 pm

Works like a charm :thumb: :fro:
Again some requests ;)
- does it possible to keep the selection but separated like when you make a normal PushPpull with CTRL ?
- make a Scale on each face

This last must be asked also for Fredo Scale :)
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: LuchoLopez and 11 guests

Visit our sponsors: