• Login
sketchucation logo sketchucation
  • Login
πŸ”Œ Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

Material by Layer in Ruby

Scheduled Pinned Locked Moved Developers' Forum
11 Posts 5 Posters 1.5k Views 5 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.
  • T Offline
    todd burch
    last edited by 24 Jan 2008, 12:47

    Materials don't have layers. Faces and edges have layers and materials.

    Todd

    1 Reply Last reply Reply Quote 0
    • A Offline
      Al Hart
      last edited by 24 Jan 2008, 15:34

      @unknownuser said:

      Materials don't have layers. Faces and edges have layers and materials.

      Todd

      That is true. However they have a thing that acts a lot like a material in the Color by Layer dialog:

      layer-mat.jpg

      We are able to extract the texture image from this, but not the size.

      We are able get both using Skp_Reader (C++ code), but cannot access them from Ruby.

      Al Hart

      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • R Offline
        RickW
        last edited by 24 Jan 2008, 17:29

        Materials don't have layers, but layers can have materials. πŸ˜„

        Unfortunately, Google has not provided ruby access to the layer material. 😞

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

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 24 Jan 2008, 18:46

          I wrote this work around a while ago... It does it by making an obj export of the model set 'material by layer' temporarily, and then using its mtl file to get the layers and colours... that's as good as it gets... You could use the data from the temp file rather than write a csv ? You could even export it all to a temp folder and delete that at the end if required ?


          ListLayerColors.rb

          TIG

          1 Reply Last reply Reply Quote 0
          • T Offline
            todd burch
            last edited by 24 Jan 2008, 19:12

            Al, since you can get to the data you need via the SDK, write a C/C++ extension that returns the data to Ruby.

            Todd

            1 Reply Last reply Reply Quote 0
            • A Offline
              Al Hart
              last edited by 25 Jan 2008, 15:51

              We are going to write an Exporter, but that has the disadvantage of only working with the Professional version of SketchUp.

              We can write an external program using SKP_Reader, but that will require that the user save the current model before rendering it.

              We would like to get this information from the current model, in the free version, without saving the model. (If possible)

              @unknownuser said:

              Al, since you can get to the data you need via the SDK, write a C/C++ extension that returns the data to Ruby.

              Todd

              Al Hart

              http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
              IRender nXt from Render Plus

              1 Reply Last reply Reply Quote 0
              • T Offline
                todd burch
                last edited by 25 Jan 2008, 16:01

                What's wrong with this agonizing approach:

                • create an "array entry" for every layer
                • For every group/component/entity...
                • determine if it has any material associated with it
                • if so, for it's layer "array entry", add the material to it as a subarray
                  When done, you have an array of layers, and each layer records the materials in it.

                From the first post, I thought I was missing the obvious. This is the obvious approach.

                Since materials don't have layers, but objects have both materials and layers, you just have to run the objects and make your own list. From my perspective, no big deal - it's just not a quick call to any singe method to get it done.

                Todd

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tbd
                  last edited by 25 Jan 2008, 16:03

                  pitty that Sketchup.active_model.sapidoc is not available in SU6 anymore 😞

                  SketchUp Ruby Consultant | Podium 1.x developer
                  http://plugins.ro

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    Al Hart
                    last edited by 25 Jan 2008, 16:05

                    Shoot! 😞

                    This was a good idea TIG, but the .mtl file does not contain the texture size information.

                    @unknownuser said:

                    Alias OBJ Material File

                    Exported from SketchUp, (c) 2000-2006 Google, Inc.

                    newmtl Layer0
                    Ka 0.000000 0.000000 0.000000
                    Kd 1.000000 0.000000 0.000000
                    Ks 0.330000 0.330000 0.330000
                    map_Kd test4/Layer0.jpg

                    Kd is the color, but when I change the texture size and export it again, nothing in the file changes to match it.

                    I guess we'll have to write our own exporter...

                    @tig said:

                    I wrote this work around a while ago... It does it by making an obj export of the model set 'material by layer' temporarily, and then using its mtl file to get the layers and colours... that's as good as it gets... You could use the data from the temp file rather than write a csv ? You could even export it all to a temp folder and delete that at the end if required ?

                    Al Hart

                    http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                    IRender nXt from Render Plus

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      Al Hart
                      last edited by 25 Jan 2008, 16:07

                      We will look at this again, but I believe the group/component/entity will report its own material and not the "Color by Layer" material.

                      But we will try it. It would be a shame to miss the obvious answer.

                      TextureHelper lets us save copies of the texture file for the layer, but neither Texture Helper of UVQHelper seem to let us access the texture size.

                      @unknownuser said:

                      What's wrong with this agonizing approach:

                      • create an "array entry" for every layer
                      • For every group/component/entity...
                      • determine if it has any material associated with it
                      • if so, for it's layer "array entry", add the material to it as a subarray
                        When done, you have an array of layers, and each layer records the materials in it.

                      From the first post, I thought I was missing the obvious. This is the obvious approach.

                      Since materials don't have layers, but objects have both materials and layers, you just have to run the objects and make your own list. From my perspective, no big deal - it's just not a quick call to any singe method to get it done.

                      Todd

                      Al Hart

                      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                      IRender nXt from Render Plus

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

                      Advertisement