• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Creating a material from an existing one

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 3 Posters 1.2k Views
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.
  • F Offline
    fredo6
    last edited by 22 Feb 2008, 16:46

    Is this possible?
    I did not find anything in the Ruby doc about how to do that.

    What I have found is that:

    • You can create a new material by name
    • you can only assign a texture to the material by filename (it has to be a JPG)
    • However, with SU v6, the JPG is not available as a file but embedded is the SKM file of the material

    Thanks

    Fredo

    1 Reply Last reply Reply Quote 0
    • A Offline
      Al Hart
      last edited by 23 Feb 2008, 06:25

      1. If you examine the .SKM file, you will discover that it is a zip file with the material stored in it. So if you have a way to read the zip file from Ruby, you can access it.

      2. Another way we get the texture is to assign the material to a face or image and use TextureWriter to write the textures to a file. (If it is a "distorted" texture, it will not write the original texture, but rather the texture as it appears on the face.)

      Al Hart

      http://wiki.renderplus.com/images/e/ef/Render_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • F Offline
        fredo6
        last edited by 23 Feb 2008, 09:00

        @al hart said:

        1. If you examine the .SKM file, you will discover that it is a zip file with the material stored in it. So if you have a way to read the zip file from Ruby, you can access it.

        This is good to know, but it would be rather convoluted, especially for the objective I research which is just a script to put the selection in Xray, while the rest of the model is unchanged.

        @al hart said:

        1. Another way we get the texture is to assign the material to a face or image and use TextureWriter to write the textures to a file. (If it is a "distorted" texture, it will not write the original texture, but rather the texture as it appears on the face.)

        I played with the Texturewriter of course, with a Load from a face, but the method filenamedoes not even return anything!

        Actually, the question is not really to get the texture, but to create a material as a clone of another one, and then change some parameters(in my case the transparency via the Alpha method). You can do all this with the User Interface of the Sketchup paint bucket, but apparently the Ruby API is far behind.

        Thanks for your help.

        1 Reply Last reply Reply Quote 0
        • A Offline
          Al Hart
          last edited by 23 Feb 2008, 16:43

          Did you call tw.write(entity, fname)

          Al Hart

          http://wiki.renderplus.com/images/e/ef/Render_plus_colored30x30%29.PNG
          IRender nXt from Render Plus

          1 Reply Last reply Reply Quote 0
          • F Offline
            fredo6
            last edited by 23 Feb 2008, 16:45

            @al hart said:

            Did you call tw.write(entity, fname)

            No. My intention is not to export material or even get the JPG file for the texture, but just clone a material within the model, and then change parameters of this new material.

            1 Reply Last reply Reply Quote 0
            • A Offline
              Al Hart
              last edited by 23 Feb 2008, 16:51

              We have a similar function.

              The material is on a face. We use tw.write to ave the raster image to a temporary file, and then use the image to create a new material.

              Al Hart

              http://wiki.renderplus.com/images/e/ef/Render_plus_colored30x30%29.PNG
              IRender nXt from Render Plus

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by 23 Feb 2008, 16:58

                @unknownuser said:

                @al hart said:

                Did you call tw.write(entity, fname)

                No. My intention is not to export material or even get the JPG file for the texture, but just clone a material within the model, and then change parameters of this new material.

                I agree about needing to read or write on the disk in order to accomplish this; however... if you are going to be reading and writing files, why not copy the .skm, load it, and make the adjustments? Either way, it looks as if the best you are going to do is a clunky work-around.

                Hi

                1 Reply Last reply Reply Quote 0
                • F Offline
                  fredo6
                  last edited by 23 Feb 2008, 17:07

                  @jim said:

                  I agree about needing to read or write on the disk in order to accomplish this; however... if you are going to be reading and writing files, why not copy the .skm, load it, and make the adjustments? Either way, it looks as if the best you are going to do is a clunky work-around.

                  Well, this is to create programmatically a semi-transparent material from an existing material. This is the only way to build a macro that would show part of the model in Xray (as the View mode of Sketchup applies to the whole model). At the moment, I can do it with color of material, but cannot get the textures to be Xray'ed.

                  See discussion thread in the forum at http://www.sketchucation.com/forums/scf/viewtopic.php?f=57&t=6638
                  and also in the French section (http://www.sketchucation.com/forums/scf/viewtopic.php?f=51&t=6589&start=0 )


                  model from Claire

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

                  Advertisement