sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Working with textures on multiple faces?

    Scheduled Pinned Locked Moved Plugins
    3 Posts 2 Posters 995 Views 2 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.
    • S Offline
      SurfingAlien
      last edited by

      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

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

        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"]...
        🤓

        TIG

        1 Reply Last reply Reply Quote 0
        • S Offline
          SurfingAlien
          last edited by

          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

          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