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

    Using default sketchup materials with Ruby API

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 4 Posters 1.7k Views 4 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.
    • M Offline
      mocathe1st
      last edited by

      I think I'm missing something in the docs, but can anyone tell me how to assign default sketchup materials to faces? The docs seem to be for Sketchup 4 and talks about .jpg files.

      I tried the following code but it just changes the material to black:
      materials = Sketchup.active_model.materials

      
      m = materials.add "opening"
      m.texture="c;\\Program Files\\@Last Software\\Google SketchUp 6\\Materials\\Translucent\\Translucent_Glass_Sky_Reflection.skm"
      face.material = m
      
      

      Any help would be great.

      Thanks.

      1 Reply Last reply Reply Quote 0
      • R Offline
        RickW
        last edited by

        Do you really have GSU6 installed under "@Last Software" ??
        That would be my first guess.

        RickW
        [www.smustard.com](http://www.smustard.com)

        1 Reply Last reply Reply Quote 0
        • C Offline
          CPhillips
          last edited by

          I dont know if this is your problem or not but...

          I found a bug a while back where if I tried to apply a material with a texture that wasn't already in the model it would to unpredictable things including crash. Try adding that material to something by hand before you try to assign in using ruby.

          Chris

          @mocathe1st said:

          I think I'm missing something in the docs, but can anyone tell me how to assign default sketchup materials to faces? The docs seem to be for Sketchup 4 and talks about .jpg files.

          I tried the following code but it just changes the material to black:
          materials = Sketchup.active_model.materials

          
          > m = materials.add "opening"
          > m.texture="c;\\Program Files\\@Last Software\\Google SketchUp 6\\Materials\\Translucent\\Translucent_Glass_Sky_Reflection.skm"
          > face.material = m
          > 
          

          Any help would be great.

          Thanks.

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

            This code works for me:

            model = Sketchup.active_model
            materials=model.materials

            Adds a material as an in model material

            m = materials.add "Test Color"
            begin

            Returns nil if not successful, path if successful

            path=Sketchup.find_support_file "1.jpg","\Plugins\"
            # m.texture = "1.jpg"
            m.texture = path
            m.texture.size = 666
            rescue
            UI.messagebox $!.message
            end

            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