sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    How to add texture on a plane into a script?

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 527 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.
    • S Offline
      sahi
      last edited by

      How to add texture on a plane into a script?

      
      material = model.materials
      base = entities.add_face(pts)
      base.material = ????
      
      
      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        From here: http://download.sketchup.com/OnlineDoc/gsu6_ruby/Docs/ruby-drawingelement.html#material=

        material = drawingelement.material = material | "materialname" | color | "colorname"
        

        The right-hand-side can be a Material object, a material name (String), a Color object, or a color name (String)

        So...

        
        base.material = Sketchup;;Color.new(255, 0, 0) # Color
        base.material = 255 # Color
        base.material = 0xff # Color
        base.material = "red" # Color
        base.material = "#ff0000" # Color
        base.material = [1.0, 0.0, 0.0] # Color
        base.material = [255, 0, 0] # Color
        
        

        If you want to use a Material that is already in the Model, you can get it through the Materials object.

        
        mat = Sketchup.active_model.materials["Material Name"]
        base.material = mat
        
        

        If you want to create a new Material from a image file:

        
        mat = Sketchup.active_model.materials.add "New Material Name"
        mat.texture = "c;\\path\\to\\texture\\image.png"
        base.material = mat
        
        

        Note this is from the API documentation and may contain inaccuracies.

        Hi

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

          mat = Sketchup.active_model.materials.add "New Material Name"
          mat.texture = "c;\\path\\to\\texture\\image.png"
          base.material = mat
          

          Thank you! Thank you! Thank you!

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

            how to place texture on a center?

            position_material  ????
            

            Dom_5.jpg

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

              Need to use a UVHelper - set the middle coordinate of the texture to be the same as the middle coordinate of the face (is one way).

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

              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