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

    Why Doesn't Component's Material Change?

    Scheduled Pinned Locked Moved Dynamic Components
    sketchup
    26 Posts 4 Posters 12.1k Views 4 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
      SketchUcationKid
      last edited by

      @JQL, as you suspected, the faces of the component were already painted. so I selected all the faces and set them to "Default" material, as you can see attached. then I could finally paint the component with one click using the bucket tool.

      now there's a new problem. I tried to change the component material with the "Material behavior", it says that the selected material is not in model but, as you can see, it is!

      thanks.


      SketchUcation - Material Not in Model.png

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

        yes, @Rich O Brien. it is a DC.

        1 Reply Last reply Reply Quote 0
        • Rich O BrienR Offline
          Rich O Brien Moderator
          last edited by

          It's available from the library but it's not applied to anything in the model.

          You need material applied to something before you can pick it.

          Make a small face a paint it with the material for it to be accessible in the drop down.

          The more Materials you need to more little faces you'll need to hide somewhere in your model.

          At least that was the the scenario in the past. I haven't stayed current on DC of late

          Download the free D'oh Book for SketchUp πŸ“–

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

            but this material has been used in the model, as you can see in the picture. I'm trying to change the side finishing. top and bottom finishing already have this material applied. it was supposed to work, so.

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              The usual 'trick' is to apply the materials which you wish to be used by a DC onto tiny faces [aka 'swatches'] nested inside other objects in the DC [so they are never seen].

              Then 'calling' that material by its name from within the DC code should work...

              TIG

              1 Reply Last reply Reply Quote 0
              • Rich O BrienR Offline
                Rich O Brien Moderator
                last edited by

                What I see in your picture is that the Wood material is selected in the Wood library.

                To see what's applied/available you need to set the Materials library to In Model

                Download the free D'oh Book for SketchUp πŸ“–

                1 Reply Last reply Reply Quote 0
                • JQLJ Offline
                  JQL
                  last edited by

                  @rich o brien said:

                  To see what's applied/available you need to set the Materials library to In Model

                  To see the materials you have in model, you click on the little house icon on the top left of the materials list.

                  The list will then be called "In Model", not "Wood" nor "Minecraft".

                  If you don't do what TIG suggests (swatches hidden inside the DC) you will not be able to use that DC in models that don't have those materials.

                  www.casca.pt
                  Visit us on facebook!

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

                    the material "Wood_Floor" is available in Model. so, it was supposed to work.

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      You have not demonstrated that 'Wood_Floor' is available in the model.
                      Your screen-shots show it in a collection named 'Wood', that is external to the model.
                      If you click the 'house' icon to show what's in the model is it also there ?

                      As has previously been explained a DC which doesn't have embedded swatches of materials is doomed to fail, because one day the named material will not be found...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • JQLJ Offline
                        JQL
                        last edited by

                        If you click on a material from the libraries it becomes available in model but not applied to any face.

                        You should have tiny faces hidden inside your component, each face with a material variation you need on the Dynamic Component, in order to transport the material with the component to wherever it goes.

                        www.casca.pt
                        Visit us on facebook!

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

                          please, take a look at the attached picture and tell me what is missing.


                          SketchUcation - Material Does Not Change.png

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

                            material behavoir setting.


                            SketchUcation - Material Behavior Setting.png

                            1 Reply Last reply Reply Quote 0
                            • TIGT Offline
                              TIG Moderator
                              last edited by

                              You tantalizingly never show us everything we need to make a defintive comment...

                              However, try this...
                              Open your Material Browser and set 'Wood_Floor' as the current material.
                              Paint it onto something manually.
                              Now open the Ruby Console and paste these lines + enter...

                              p Sketchup.active_model.materials.current.display_name p Sketchup.active_model.materials.current.name

                              It will show the Material's display_name and its name - note that these don't always match, depending on how the material is created / imported...
                              e.g.
                              "Wood Floor"
                              "[Wood Floor]"

                              Since the DC code needs the Material's name, then it fails if the material has been added to the model because the actual name is different from what is displayed - the surrounding [...] shows that.
                              Importing it whilst it's within the DC may well use another naming convention that will work... try it...

                              TIG

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

                                @TIG, is this your defintive comment? because it didn't work anyway. I opened Ruby Console, run both lines of code that you suggested and noticed that the white color name for both display and current's name are the same: Color_000. exactly the same name I used in the material behavior setting. it didn't change the color to white, which, according to you, it should work. the same happened to the Wood Floor material, which display and current's name are saved as Wood Floor and [Wood Floor], respectively.

                                1 Reply Last reply Reply Quote 0
                                • TIGT Offline
                                  TIG Moderator
                                  last edited by

                                  You misconstrue what I said.
                                  This IS my definitive comment !

                                  I simply want you to set 'Wood_Floor' as the current [applied] material in the model and then get its 'display_name' and 'name' - which could be different...
                                  You then confirm that they are indeed different...

                                  But somehow deny this is true ??
                                  But it is !

                                  Also I did not ask you to do anything with any other material, and I did not suggest that somehow my code snippets would change anything in the model - they were just there to report the facts !

                                  Do you not see my simple point ?

                                  Even if 'Wood_Floor' is in use in the model, then its 'displayed name' and its actual 'data-base name' might vary, so then your DC code could fail because it can't find the material 'by name' as it's not what shows in the Materials Browser dialog...

                                  BUT, if you were to include the required material applied onto a swatch hidden within your DC, then you have a much better chance that it will be recognized by name and therefore used without an error...

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • JQLJ Offline
                                    JQL
                                    last edited by

                                    Hey Kid. Do both these things:

                                    1. Don't make Tig loose his coolness, we need him to keep cool as ever πŸ˜‰.
                                    2. Do the following, step by step:
                                    • Edit the component you are making;
                                    • Draw a rectangle for each material you will need that component to have;
                                    • Paint each rectangle with the corresponding material;
                                    • Go to Material browser and hit the little house icon;
                                    • Above the list, to the right there's a blue and white arrow icon pointing right which read details when you hover over it. Click it and choose List View;
                                    • This list now shows the names of the materials you used in model;
                                    • It might also list a lot of materials you are not using but clicked on so they got into the model;
                                    • Go to the details arrow again and choose the purge option;
                                    • The material names you can use in the DC component are somewhere within the resulting list.
                                    • Never erase the squares you drew initially;
                                    • If you need to hide them from view, then shrink them as small as you wish, and hide them inside the model. (you can really hide the objects too by selecting them all, right clicking on one of them and use the hide command.)
                                    • These little squares are the swatches Tig told you about.

                                    www.casca.pt
                                    Visit us on facebook!

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

                                      @TIG, I did not misconstrue what you said. if I made you to understand so, l apologize.
                                      I have another DC which has basically the same structure (with mother component and subcomponents) and it is working pretty fine. I can change its material thru the dropdown list that I put available on the component options screen. and I didn't need to do all those changes to make it work.

                                      about the white color, what I wanted to say is that it is saved in the system as Color_000, both display and current name. I set the material behavior to the same Color_000, which was supposed to change the component color to white but it didn't happen, unsuccessfully. on the other hand, when I use the bucket tool to paint the component (not the faces), it works.

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

                                        @JQL, all of those steps were already taken by me. if you take a look at the attached pictures, you'll be able to see those "little squares", that you mentioned, placed right above the cabinet. I believe that I'm dealing with one more of many bugs found in SketchUp.

                                        I don't know what really is doing him lose his "coolness" but this chat has more to do with an air conditioner machine πŸ˜‰ .

                                        1 Reply Last reply Reply Quote 0
                                        • TIGT Offline
                                          TIG Moderator
                                          last edited by

                                          A material has to have been used in the model, simply making it current is not enough.
                                          Perhaps this is the Color_000 issue ?
                                          http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=33847

                                          As has been spelled out several times, adding small painted faces within some part of the DC is the sure way of having these available to use in the DC, however there is this potential difference between the material .name and its .display_name
                                          The enclosing [...] etc show this.
                                          Try using those for the material name, rather than the display name.
                                          The code snippet I gave allows you to get any material's dual names.
                                          I understand that the [...] indicate the material was at some time loaded into a model and not created from scratch.
                                          It has been like that since v6.0

                                          Link Preview Image
                                          Class: Sketchup::Material

                                          The Sketchup::Material class represents a Sketchup::Texture or Sketchup::Color that can be applied to Sketchup::Drawingelements.

                                          favicon

                                          SketchUp Ruby API Documentation (ruby.sketchup.com)

                                          Since you are shipping the materials you can choose the re-name them using the >=v8.0 method:
                                          material.name="some_name"

                                          A quick way to do this could be this snippet...
                                          Sketchup.active_model.materials.each{|mat| p n=mat.name; p d=mat.display_name; mat.name=d; p mat.name }
                                          This processes all of the materials currently used in the model and sets the mat's name to the display_name - thereby sidestepping any difference between the two...
                                          It prints each material's name, display_name and final name - this safety-net is in case the new name is already taken by another material, in which case it'll get a numerical suffix added...

                                          This has been cover ages ago by thomthom, here... some of his points have already been added to the API notes...
                                          http://www.thomthom.net/thoughts/2012/03/the-secrets-of-sketchups-materials/

                                          TIG

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

                                          Advertisement