[Plugin] TextureRandomizer v1.3 20120320

[Plugin] TextureRandomizer v1.3 20120320

Postby TIG » Tue Mar 20, 2012 12:27 pm

Copyright 2012 (c) TIG
All Rights Reserved.
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES,INCLUDING,WITHOUT LIMITATION,THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
###

TextureRandomizer.rb place it in the ../Plugins/ folder

###
Usage: TextureRandomizer

Used for randomizing textured materials like timber-grain on selected plank
faces etc...

Preselect at least ONE face that has a front material with a texture.
Note if a selection contains other things they are ignored.

Activate the Tool:-
'TextureRandomizer' in the Plugins menu.
OR type in the Ruby Console
TextureRandomizer.new
plus <enter>

From v1.2...
If there are any groups/component-instances in the selection, and they
contain textured-faces a dialog asks if you want to include those faces
too, answer 'No' to process selected faces only or 'Yes' to process all
textured-faces, including those inside other selected objects...
It does not 'mine' down beyond the selected context - so nested groups are
never affected.

From v1.3...
If there are non-unique groups in the accepted selection then you are asked
if you want to make them unique, so that their randomized-textures are also
unique... [groups should be 'unique', BUT Sketchup can have more than one
instance of a group !!]
If there are multiple instances of the same component in the accepted
selection then you are asked if you want to make them unique, so that their
randomized-textures are also unique... [use this with care as the advantage
of components - edit one, edit all - is lost by making instances unique!]

A dialog appears with the following initial defaults:

Position UX max: 0
Position UX min: 0
Position VY max: 0
Position VY max: 0

These numbers are in 'current units' - e.g. 100, 1cm or 1".
They can be +ve or -ve; min=-50mm to max=50mm will nudge randomly between
these two extremes; such small values to nudge textures 'across the grain'
will probably work best for timber-grain textures; larger nudges along the
grain might be more effective - experiment...
Using 0 for all values does not re-position the texture at all.

Scale UX max: 1
Scale UX min: 1
Scale VY max: 1
Scale VY min: 1

These numbers represent the scale-factor, so 1.1 is +10%.
They can be +ve or -ve; using a -ve value will 'mirror' all textures on
that axis.
Using 1 for all values does not scale the texture at all.
Any value used must be more that 0.01 or less than -0.01, a value of 0 will
be adjusted to 0.01; please remember that a tiny texture will probably be
unrecognizable; and although there is no 'upper limit' a scaling-factor
greater than ~100 would probably make the texture unrecognizably large !
Using small difference ranges [e.g. min=0.9 max=1.1] will probably give the
best results for timber-grain etc.

Random Mirroring UX: No
Random Mirroring VY: No

Choose either 'Yes' or 'No'...
With 'No' then there is no 'mirroring' on that axis.
With 'Yes' the texture will be randomly 'mirrored' about that axis using
the scaling-factors set above; so with '1' set for all scaling and 'Yes'
you'll get 'mirroring' for ~50% of the selected faces' textures, randomly.

Rotation max: 0
Rotation min: 0

The Rotation is in degrees.
The values can be +ve or -ve.
Using 0 for both angles does not rotate the texture at all.
Any value > 360 will revert to an equivalent value below 360.
Any value < -360 will revert to an equivalent value above -360.
Small ranges like max=1 and min=-1 will probably give the best results for
timber-grain etc.

All faces' material textures are now randomized to the parameters.

It is a 'one step' undoable change.

The previously used parameters are reused for the tool's dialog if it is
activated later in that same session.

TIP: Using the same value for the 'max' AND 'min' settings will make that
change with no randomization, e.g. set UXmax=1 and UXmin=1 will jump all of
the selected faces' textures across by +1 unit.

###
Donations:
info @ revitrev.org via PayPal.com
###
Versions:
1.0 20120320 First Release.
1.1 20120320 Stupid typo fixed.
1.2 20120320 Option to include textured-faces inside selected
groups/components.
1.3 20120320 Non-unique groups and instances are now spotted, and you are
asked if you want to change them.
###
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.0 20120320

Postby Vicspa » Tue Mar 20, 2012 12:40 pm

Thanks TIG :thumb:
0

Vicspa 
 

Re: [Plugin] TextureRandomizer v1.0 20120320

Postby massimo » Tue Mar 20, 2012 1:13 pm

Thanks TIG. :thumb:
However it does absolutely nothing here, no dialogue appears. :)
I got this in the ruby console:
Code: Select all
Error: #<ArgumentError: Cannot convert "1.0" to Length>
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/TextureRandomizer.rb:121:in `to_l'
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/TextureRandomizer.rb:121:in `dialog'
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/TextureRandomizer.rb:114:in `new'
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/TextureRandomizer.rb:96
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/TextureRandomizer.rb:96:in `call'
0
User avatar
massimo 
 

Re: [Plugin] TextureRandomizer v1.0 20120320

Postby AcesHigh » Tue Mar 20, 2012 2:00 pm

Awesome TIG! I am sure this can be used by a lot of people to leave their projects more realistic!
0

AcesHigh 
 

Re: [Plugin] TextureRandomizer v1.1 20120320

Postby TIG » Tue Mar 20, 2012 2:36 pm

Here's v1.1 viewtopic.php?p=392834#p392834

I fixed a stupid typo [and some incorrect 'default values'] that meant it didn't work if you use a ',' as a decimal point instead of a '.' is fixed...
[I hope this address's massimo's report]
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.1 20120320

Postby pilou » Tue Mar 20, 2012 2:54 pm

Does this a variation of only one texture or several textures ?
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] TextureRandomizer v1.1 20120320

Postby TIG » Tue Mar 20, 2012 2:58 pm

It affects ALL textured materials on ALL selected faces [fronts].
So if you want to tweak one particular face+material combo then 'select by same material' before running the tool...
Otherwise it randomizes everything !
Any selected non-faces, or faces with non-textured materials, are ignored anyway...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.1 20120320

Postby massimo » Tue Mar 20, 2012 3:07 pm

Now seems to work fine. Thank you. :)
It would be nice if it worked also with groups...
0
User avatar
massimo 
 

Re: [Plugin] TextureRandomizer v1.1 20120320

Postby TIG » Tue Mar 20, 2012 3:13 pm

massimo wrote:Now seems to work fine. Thank you. :)
It would be nice if it worked also with groups...
A textured-material applied to a group is non-editable.
Only textured-materials applied directly onto to faces are editable.
If you mean it working on textured-faces that are inside groups, then if you edit the group/component you can randomize the textures on selected faces within the edit session...
It would be possible to add extra code to process selected textured-faces AND textured-faces inside selected groups/components...
Does this method appeal to anyone else ?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.1 20120320

Postby massimo » Tue Mar 20, 2012 3:15 pm

It would be possible to add extra code to process selected textured-faces AND textured-faces inside selected groups/components...

That's what I meant.
0
User avatar
massimo 
 

Re: [Plugin] TextureRandomizer v1.2 20120320

Postby TIG » Tue Mar 20, 2012 3:43 pm

Here's v1.2 viewtopic.php?p=392834#p392834
If there are any groups/component-instances in the selection, and they
contain textured-faces a dialog asks if you want to include those faces
too, answer 'No' to process selected faces only or 'Yes' to process all
textured-faces, including those inside other selected objects...
It does not 'mine' down beyond the selected context - so nested groups are
never affected.
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.2 20120320

Postby pilou » Tue Mar 20, 2012 4:27 pm

Cool effect! :enlight:

Before use your plug above
[REQ]
Does it possible to apply to a selection of faces some textures randomly from the Texture library ?
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] TextureRandomizer v1.2 20120320

Postby massimo » Tue Mar 20, 2012 5:37 pm

Great. :thumb:
Now the problem is that all the selected groups are "randomized" in the same way (I've tried with an array of the same textured group). So at the end you have... a different uniformity. :D
1
User avatar
massimo 
 

Re: [Plugin] TextureRandomizer v1.2 20120320

Postby EarthMover » Tue Mar 20, 2012 9:08 pm

Nice plugin TIG. Thanks! Possible to add an option for color variation by HSB? Perhaps random slide by percent for Hue,Saturation or black value. Would be great for leaves, brick, stones, etc.
0
3D Artist at Clearstory 3D Imaging
Guide Tool at Winning With Sketchup
Content Creator at Skapeup
User avatar
EarthMover 
Premium Member
Premium Member
 

Re: [Plugin] TextureRandomizer v1.2 20120320

Postby TIG » Tue Mar 20, 2012 9:26 pm

massimo wrote:Great. :thumb:
Now the problem is that all the selected groups are "randomized" in the same way (I've tried with an array of the same textured group). So at the end you have... a different uniformity. :D
This is NOT a problem with the tool, rather one with the model itself.
So this is not entirely true. :o
If groups are multiple instances of the same group-definition they are just like component-instances of the same component-definition, so all changes to one will look just the same across all instances.
BUT if groups are unique because they have been edited [equivalent to what you can do with component-instances and 'make-unique' in the context-menu]... then the texture changes WILL be unique to each unique instance of the group.
So in essence what you are saying is, "Multiple copies of a group which refer to the same group-definition [which you can see in the 'Entity Info' count!] will display the same random-texture changes, because they are all 'clones'..." - which is exactly as you should expect. :roll:
So you need to edit the groups [without making any significant changes] which will make them unique, and then redo the texture-randomization and then each one will get a unique texture randomization...
To make your groups unique you can try this simple one-liner in the Ruby Console, use it on a preselected set of entities which include the groups you want to 'make unique'...
Code: Select all
Sketchup.active_model.selection.each{|e|e.make_unique if e.class==Sketchup::Group and e.entities.parent.instances[1]}
You might get messages about '...deprecated methods...', but just ignore these as there's a long standing balls-up in the API ! :geek:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.2 20120320

Postby TIG » Tue Mar 20, 2012 9:30 pm

EarthMover wrote:Nice plugin TIG. Thanks! Possible to add an option for color variation by HSB? Perhaps random slide by percent for Hue,Saturation or black value. Would be great for leaves, brick, stones, etc.
This would require a new textured-material [which is of course quite possible] - but this specific tool only randomizes the position/scale/mirroring/rotate of the one textured-material without changing it in any other way except for its UV-mapping...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.2 20120320

Postby massimo » Tue Mar 20, 2012 9:48 pm

Ok, ok...As I suspected. Now your one-liner works like a charm. Any possibility to "incorporate" it in the plugin perhaps as an option? :)
0
User avatar
massimo 
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby TIG » Wed Mar 21, 2012 12:41 am

Here's v1.3 viewtopic.php?p=392834#p392834
If there are non-unique groups in the accepted selection then you are asked
if you want to make them unique, so that their randomized-textures are also
unique... [groups should be 'unique', BUT Sketchup can have more than one
instance of a group !!]
If there are multiple instances of the same component in the accepted
selection then you are asked if you want to make them unique, so that their
randomized-textures are also unique... [use this with care as the advantage
of components - edit one, edit all - is lost by making instances unique!]
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby pilou » Wed Mar 21, 2012 12:48 am

Give a random colors to a volume is easy with the Random Painter by Chris Fullmer
but random textures from the Library of textures?
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby EarthMover » Wed Mar 21, 2012 2:23 am

Thanks for the reply. I guess it would be best served as a separate plugin called "Texture Variator" or something similar where one could enter the number of variations desired and the range of HSB, thus producing copies and replacing the existing. Texture Randomizer as you have created it works great in my tests and again I thank you for your efforts and generosity! It is a handy addition to your texture toolset which I use everyday. :thumb:
0
3D Artist at Clearstory 3D Imaging
Guide Tool at Winning With Sketchup
Content Creator at Skapeup
User avatar
EarthMover 
Premium Member
Premium Member
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby massimo » Wed Mar 21, 2012 8:03 am

Thanks again TIG. Your patience is equal to your abilities... :thumb:
0
User avatar
massimo 
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby TIG » Fri Mar 23, 2012 3:32 pm

TIP: Using the same value for the 'max' AND 'min' settings will make that change with no randomization, e.g. set UXmax=1 and UXmin=1 will jump all of the selected faces' textures across by +1 unit.
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby guanjin » Sat Mar 24, 2012 10:22 am

TIG wrote:TIP: Using the same value for the 'max' AND 'min' settings will make that change with no randomization, e.g. set UXmax=1 and UXmin=1 will jump all of the selected faces' textures across by +1 unit.

未命名.jpg

The plane can not be adjusted, the tool does not work
0
I come from China, is to learn
User avatar
guanjin 
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby TIG » Sat Mar 24, 2012 11:18 am

Explain how it is "not working" !
Your bug reports can be annoyingly brief and unclear. :roll:

Is your textured-material applied directly to a face and NOT a group/component-instance - remember that you CANNOT adjust textures unless they are applied directly to a face - that applies to either with this tool or using the native Texture tool available through the context-menu...

Is the texture-material applied to a 'front' face - you cannot adjust the texture that are incorrectly applied to a 'back' face.
If your rectangle was drawn on the ground and you haven't reversed the face then you have textured the back NOT the front !
To check this... ensure your Style has a distinct color difference between front and back default materials - typically an off-white and a blue-gray respectively - now toggle the view between Monochrome mode and Textured mode. Faces that are textured incorrectly on their backs will show 'blue'; they need to be Reversed [context-menu] and the texture applied to their fronts - it will now be editable using this tool :geek:
Capture.PNG


If this is not the case [my best guess!]...
What values do you have in the tool's dialog?
If the max/min for a pair of setting are the same number [that is NOT 0] then the texture[s] WILL change by the fixed amount [without any randomization].

If you are working in mm and enter 1 then the 1mm jump could be hard for you to see unless you are close to it as it changes.
Also, if your pattern repeats at say 150mm and you also enter 150... then although the texture will jump over by that value it will once again starting in the same place... so you will see no change.

I know this tool works perfectly well - I have tested it extensively - so you must be doing something wrong. :?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.0 20120320

Postby guanjin » Sat Mar 24, 2012 11:30 am

vicspa wrote:Thanks TIG :thumb:


444.gif
0
I come from China, is to learn
User avatar
guanjin 
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby TIG » Sat Mar 24, 2012 11:35 am

Can you provide a simpler example.
[Reread my previous post about 'reversed' faces]
Unless you have a face selected that has a front-material with a texture the tool won't run.
I can't see exactly what you are doing to get nothing happening...
Regarding the rotation - remember that there is no way of knowing a textures current rotation - so any rotation you apply is relative to its current transformation, it is not 'absolute' - so rotating a texture by 45 then by 45 later is equivalent to one rotation of 90; you do not set the texture's rotation to 45, rather you change it by 45 degrees. [also remember that positive angles rotate counter-clockwise, negative angles clockwise]
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby guanjin » Sat Mar 24, 2012 11:54 am

TIG wrote:Can you provide a simpler example.
[Reread my previous post about 'reversed' faces]
Unless you have a face selected that has a front-material with a texture the tool won't run.
I can't see exactly what you are doing to get nothing happening...
Regarding the rotation - remember that there is no way of knowing a textures current rotation - so any rotation you apply is relative to its current transformation, it is not 'absolute' - so rotating a texture by 45 then by 45 later is equivalent to one rotation of 90; you do not set the texture's rotation to 45, rather you change it by 45 degrees. [also remember that positive angles rotate counter-clockwise, negative angles clockwise]



2D plane can not use this tool.
0
I come from China, is to learn
User avatar
guanjin 
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby guanjin » Sat Mar 24, 2012 11:59 am

guanjin wrote:
TIG wrote:Can you provide a simpler example.
[Reread my previous post about 'reversed' faces]
Unless you have a face selected that has a front-material with a texture the tool won't run.
I can't see exactly what you are doing to get nothing happening...
Regarding the rotation - remember that there is no way of knowing a textures current rotation - so any rotation you apply is relative to its current transformation, it is not 'absolute' - so rotating a texture by 45 then by 45 later is equivalent to one rotation of 90; you do not set the texture's rotation to 45, rather you change it by 45 degrees. [also remember that positive angles rotate counter-clockwise, negative angles clockwise]


Chose not 2D plane, sliding into the entity can
2D plane can not use this tool.
0
I come from China, is to learn
User avatar
guanjin 
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby TIG » Sat Mar 24, 2012 12:33 pm

2D plane can not use this tool.
OH YES it can. :?
I works just fine if the face is made and textured properly.
Reread my earlier post and see the illustration about 'back' face issues.
YOU have your supposed 'problem' face 'upside down'!
You have applied the textured-material onto its back NOT onto its front, where it should be!
Please 'Reverse' the face and apply the textured-material correctly onto its front.
My tool only adjusts textured-materials applied onto the fronts of faces.
You should never be applying any materials to the backs of faces - it is very bad practice - if you ever come to render a model using most 3rd-party renderers you'll get unexpected results - most of them will render back faces as black/white/transparent, completely ignoring any applied textured-materials [the result varies with the app.].

Always consider you model as made of 'solids' with faces that have their 'fronts' looking outwards towards the viewer - then there is no need to ever apply materials to the back face.

When you draw a new rectangular/circular/etc face at Z=0 [on the ground] Sketchup automatically makes it 'face down', this is because it is assuming you will PushPull it into a volume and therefore the initially downwards looking face is correctly oriented for when it becomes the bottom face of a solid.
You can easily 'Reverse' [context-menu] any faces drawn this way if you do not intend to PushPull the, and especially if you are going to add materials to them, because once they have materials you cannot differentiate between a face's front and its back unless you use Monochrome mode to view, or you use a tool that does differentiate like a 3rd party renderer or my tool !
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] TextureRandomizer v1.3 20120320

Postby guanjin » Sat Mar 24, 2012 1:17 pm

Thank you TIG: I see a positive paste material must be flipped faces :berserk:
-1
I come from China, is to learn
User avatar
guanjin 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: raphaelbelt and 7 guests

Visit our sponsors: