Working with textures on multiple faces?
-
Hi!
hope it's the right place to ask... I saw different great UV and textures plugins and tried some of them but still have to find one that let me simply do what the built-in texture/position does but with multiple faces. it could be done with UV projections too but I would think there's another way, involving scale/nudge/rotate of multiple faces at once?
I searched using various words but haven't found nothing... sorry if it's been discussed before
thanks,
Alessandro -
My TextureTools [TextureRotate.rb also contains lots of additional tools!] allowing the nudge/rotate/scale etc either by arrow-key or dialog-entered amount.
However, it only works on one face at a time when run from the menu/toolbar...
However, three of the options can take an argument [as a string], and then you don't get a dialog, so you can use them within another tool's 'method'...TextureTools::Rotate.new(angle_as_string_in_degrees)
e.g. '45.0'***TextureTools::Shunt.new(u_distance_as_string_in_units, v_distance_as_string_in_units)
e.g. '1"','0'***TextureTools::Scale.new(u_factor_as_string_float, v_factor_as_string_float)
e.g. '1','0.5'***[i.e. Within a ' ' you can use ',' as the decimal separator instead of '.' and it will still work OK]
So... YOU can easily write a simple def method to do this [I recommend you wrap it in your own module...] - e.g. if you have a number of faces in a selection and you want to rotate all of their textures by 45 degrees, you make an array of those faces, and then process each in turn [i.e. works on one selected face], by the given angle thus
<span class="syntaxdefault">def rotate_textures_on_selected_faces</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">angle</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> angle</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">angle</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_s </span><span class="syntaxcomment">### makes passed values a string anyway<br /></span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /> ss</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection<br /> ssa</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">ss</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_a<br /> faces</span><span class="syntaxkeyword">=[]<br /></span><span class="syntaxdefault"> ss</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">|</span><span class="syntaxdefault">faces </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> e if e</span><span class="syntaxkeyword">.class==</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Face</span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_operation</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"TextureTools;;Rotate.new(#{angle})"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> ss</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">clear<br /> faces</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">face</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> ss</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">face</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> TextureTools</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Rotate</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">angle</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> ss</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">clear<br /> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> ss</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ssa</span><span class="syntaxkeyword">)</span><span class="syntaxcomment">### original selection is restored<br /></span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">commit_operation<br />end</span><span class="syntaxcomment">#def<br /></span><span class="syntaxdefault"> </span>
To run it type in the Ruby Console
rotate_textures_on_selected_faces 45.0
***Note there is no need to add the ' ' - the Rotate tool is expecting a string... BUT the type of the passed 'angle' is adjusted using.to_s
at the start of the new method to sort it for you.It'd be similar methods with the other tools but two arguments are needed for those u,v...
IF you are passing units to 'Shunt' use '100mm' [or '100' to give 100mm IF the current units are 'mm'], note that passing a raw float [100] always defaults to inches [100"]...
-
thanks TIG,
of course yours was one of the plugins I was talking about and as you said it works only with single faces.
I will try what you suggested and let you know if I succeed...
cheers,
Alessandro
Advertisement