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

    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.
    • Al HartA Offline
      Al Hart
      last edited by

      We are trying to access Material by Layer information, using Ruby, for rendering and RPS 3D PDF.

      We are able to extract the texture image for the material using Texture Writer.

      However, we could not access the material size, and other information.

      We can do this using the SDK exporter, but we would prefer to do it directly in Ruby.

      Has anyone been able to access the material assigned to a layer from Ruby?

      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

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

        Todd

        1 Reply Last reply Reply Quote 0
        • Al HartA Offline
          Al Hart
          last edited by

          @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

            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
            • TIGT Offline
              TIG Moderator
              last edited by

              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

                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
                • Al HartA Offline
                  Al Hart
                  last edited by

                  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

                    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
                    • tbdT Offline
                      tbd
                      last edited by

                      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
                      • Al HartA Offline
                        Al Hart
                        last edited by

                        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
                        • Al HartA Offline
                          Al Hart
                          last edited by

                          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
                          • First post
                            Last post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement