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

    Massmaterialimportant.rb woes

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 1.2k Views 3 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.
    • EdsonE Offline
      Edson
      last edited by

      hi tig,

      i am having a little problem with this script. it works fine as far as importing goes.

      i am trying to import a number of wood textures into a skp file. the problem i am having is that no matter what texture i choose to import it keeps importing the first one.

      is there a solution for that? or, am i doing something wrong?

      cheers.

      edson mahfuz, architect| porto alegre • brasil
      http://www.mahfuz.arq.br

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

        This is the entire code [I tweaked it almost two years ago...]

        #This script was created by Adam Beazley for public use and may be edited.
        #http://www.abeazleydesign.com
        #Directions
        #Just click in the Import Materials button in the plugins menu and type in the location of all of you image files.
        #This script will create a material and name it the same name as the image file and then use that file as the texture.
        #all textures will come in at a standard scale and must be edited later
        #after all materials and textures have been imported into the model, simply add them to your library
        #you can then save the library as a .skm library file through sketchup.
        #have fun!!!
        #
        ### v1.1 TIG tweaks 29/12/05 ###
        #-----------------------------------------------------------------------------
        require 'sketchup.rb'
        #-----------------------------------------------------------------------------
        def materialimporter
           model= Sketchup.active_model
           materials= model.materials
           model.start_operation ("Import Materials") ###undo - see commit at end
           pwd= Dir.getwd.split("/").join("\\")+"\\" ### fix for SU
           dry= UI.openpanel "To Pick this Directory; Pick Any Image File + OK...", pwd , "*.???"
           ### for jpg or png
           return nil if not dry
           dry= File.dirname(dry)
           return nil if not dry
           cwd= Dir.chdir(dry)
           images= Dir["*.{jpg,png,tif,bmp,gif,tga,epx}"]### for all supported image file types
           for image in images
              imgname= image.split(".")[0..-2].join(".") ### removes .jpg etc from end
              mat= materials.add imgname
              mat.texture= image
           end#for image###
           model.commit_operation ###undo all if needed
        end#def###
        if(not file_loaded?("massmaterialimporter.rb"))
            menu=UI.menu("Plugins")
            menu.add_separator
            menu.add_item("Import Materials") { materialimporter }
        end
        #-----------------------------------------------------------------------------
        file_loaded("massmaterialimporter.rb")
        #
        

        Works fine for me ?

        TIG

        1 Reply Last reply Reply Quote 0
        • W Offline
          Whaat
          last edited by

          This may have nothing to do with it but I have been burned using this type of code before:

          imgname= image.split(".")[0..-2].join(".") ### removes .jpg etc from end
          

          Maybe he is using weird filenames that aren't properly handled by this code. (eg. "my.texture.jpeg")

          Can you post the names of the files you are trying to import?

          SketchUp Plugins for Professionals

          1 Reply Last reply Reply Quote 0
          • EdsonE Offline
            Edson
            last edited by

            better than that, i will post the files.

            http://www.sketchucation.com/forums/scf/sas/Ruby/BOARD01.JPG

            http://www.sketchucation.com/forums/scf/sas/Ruby/WOO003.JPG

            http://www.sketchucation.com/forums/scf/sas/Ruby/ratty_wood.jpg

            http://www.sketchucation.com/forums/scf/sas/Ruby/garden_wood_slats_color.jpeg

            edson mahfuz, architect| porto alegre • brasil
            http://www.mahfuz.arq.br

            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