• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

How to Obtain Length and Width Values from the Material Panel via SketchUp Ruby API?

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 3 Posters 29 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.
  • K Offline
    kitesoul99
    last edited by 15 days ago

    How can I obtain the length and width values from the material panel using the SketchUp Ruby API?

    I’ve checked the official SketchUp Ruby API documentation, but I couldn’t find a method that solves this issue. I also tried searching on Google and with AI tools, but still haven’t found an effective solution.

    See the image below for reference:

    !!Snipaste_2025-06-06_14-32-47.jpg

    If anyone has experience with this or knows how to retrieve these values through the API, I would really appreciate your help!

    Thanks in advance!!

    D 1 Reply Last reply 14 days ago Reply Quote 0
    • G Offline
      Gábor
      last edited by 14 days ago

      I am not a SU Ruby expert, but I think you can get and modify the dimensions for only those materials which has texture assigned to them and they has been added to the model. Then you can use Sketchup.active_model.materials[x] to get the material and then you can modify it's attributes.

      Others might have better ideas...

      K 1 Reply Last reply 14 days ago Reply Quote 0
      • D Offline
        Didier Bur @kitesoul99
        last edited by Didier Bur 6 Oct 2025, 10:38 14 days ago

        @kitesoul99

        Here is a little snipet
        Open the console, load the RB and type: matTexture

        def matTexture()
        	model = Sketchup.active_model
        	materials = model.materials
        	mat = Sketchup.active_model.materials.current
        	mat_name = mat.display_name
        	texture = mat.texture
        	if texture
        		t_height = texture.height
        		t_width = texture.width
                        UI.messagebox( "Material " + mat_name + "\n\nCurrent size:\n" + "Height: " + t_height.to_s + " inches\n" + "Width: " + t_width.to_s + " inches")
                else
                        UI.messagebox("No texture applied to this material",MB_OK)
        	end
        	
        end
        
        

        Please select a material first
        Retrieved values are in INCHES
        Hope this helps

        DB

        K 1 Reply Last reply 14 days ago Reply Quote 2
        • K Offline
          kitesoul99 @Gábor
          last edited by 14 days ago

          @Gábor Thanks for the suggestion! I actually tried this before posting, but it didn’t give me the length and width values I was looking for.

          Still appreciate your help!

          1 Reply Last reply Reply Quote 0
          • K Offline
            kitesoul99 @Didier Bur
            last edited by 14 days ago

            @Didier-Bur Awesome, thanks a lot! Your method worked like a charm — exactly what I needed.

            Really appreciate your support!

            Cheers!

            D 1 Reply Last reply 10 days ago Reply Quote 0
            • D Offline
              Didier Bur @kitesoul99
              last edited by 10 days ago

              @kitesoul99

              Above is a little enhancement: select the material before typing matTexture in the console.
              Regards

              DB

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              1 / 1
              • First post
                5/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement