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

Nested IF in a SET Function - what am I doing wrong?

Scheduled Pinned Locked Moved Dynamic Components
sketchup
11 Posts 4 Posters 9.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.
  • C Offline
    CharlieGirl
    last edited by 14 Jul 2010, 02:46

    Hi everyone. I'm pretty new to SketchUp so I apologize in advance if this is a dumb or repeat question. I did search pretty much all day and have not found the answer yet, so I'm hoping someone can help me. Here is what I am doing. I have created a dynamic component that is a wall with various types and colors of cladding. I have created my "swatch" of colors/textures and I have attached it to my wall. I bundled the wall and swatch as a component. I have a user input drop-down at the parent level which asks the user if they want siding, brick veneer, stone veneer, or stucco. Each response has a value, 1-4. At the "Wall" child level I have an "onClick" Behavior that should allow the user to click through the various looks and shades for each of the cladding types based on their answer from the drop-down. To do this, I used the SET function but then nested IF statements within. It is going to the correct part of the SET function, but instead of cycling through the types of materials, it is trying to find a material with the name of the entire set. Here is a small example of what I am doing and how SU is responding: SET("Material",(IF(AG Wall!Ext_Cladding=1,("Siding_Light","Siding_Color_Med","Siding_Tan_Med","Siding_Dark"),IF(AG Wall!Ext_Cladding=2,("Brick_Light","Brick_Tan_Medium","Brick_Medium","Brick_Dark"),IF(AG Wall!Ext_Cladding=3,("sketch-stone_Light","Stone_Med","dark-sketch-stone"),("Stucco_Light","Stucco_Med","Stucco_Dark")))))) When, for instance, my user selects "Stucco", this is resolved to "4" but the "Material" Behavior displays Stucco_Light","Stucco_Med","Stucco_Dark just like that, without the beginning and ending double-quotes. So I know it is getting to the correct place, but why doesn't it read the list as a list and click through the options? I appreciate any help!

    1 Reply Last reply Reply Quote 0
    • C Offline
      CharlieGirl
      last edited by 6 Aug 2010, 17:35

      220 people so far have read this, but no one has replied. Does anyone have ANY ideas about this? I really appreciate any help with it. Are there Google SketchUp programmers that watch this forum? Do I need to contact Google directly? Help!

      1 Reply Last reply Reply Quote 0
      • C Offline
        Chris Fullmer
        last edited by 6 Aug 2010, 20:12

        I read the original post once and thought it was too complex try and debug in a short amount of time. But I know its frustrating not getting help. So lets look at this. Do you have the component, or a test component you could upload here for us to look at?

        And to recap, what basic idea you want to have happen. The user chooses a material from a list and it gets applied to the component? Is it more than that?

        Chris

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 6 Aug 2010, 20:43

          I agree with Chris.
          The question is too complex.
          Supply a skp and some simple step-sheet explanations of what you expect the user to do and what should happen and what is happening - forget too much 'coding' initially...
          Then we can help you... 🤓

          TIG

          1 Reply Last reply Reply Quote 0
          • C Offline
            CharlieGirl
            last edited by 10 Aug 2010, 19:47

            Thank you very much. I have attached my wall dynamic component.

            What I am trying to make happen is this:

            1. The user selects a siding type in the Component Options dialog box, brick, stucco, etc.

            2. The user interacts with the component by clicking on the wall and the wall cycles through the appropriate swatches to display the siding type as either light, medium, or dark.

            I have the swatches attached to the component and it works when I cycle through only one type, but when I nest my If statement, it stops working.

            I really appreciate you taking another look at this!

            1 Reply Last reply Reply Quote 0
            • C Offline
              Chris Fullmer
              last edited by 10 Aug 2010, 23:28

              ok, so the user can select one a few different types of materials from a drop down menu. Then by clicking ont he component, the component should switch between light, medium and dark variations of the material.

              That should be do-able. I'll see if I can look through the component when I get a chance. Thanks for posting it,

              Chris

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • C Offline
                Chris Fullmer
                last edited by 11 Aug 2010, 00:32

                ok, assuming I understood the problem at hand, I went ahead and made a DC that does what you want. The user can choose one of 4 colors from a list. Then upon OnClick'ing on the component, it changes between dark, medium, and light of that color. I'll attach the DC and you can check it out. Or if I get a chance, I'll look yours over and see if I can spot the error.

                Chris


                color_clicker.skp

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

                1 Reply Last reply Reply Quote 0
                • C Offline
                  CharlieGirl
                  last edited by 11 Aug 2010, 13:14

                  Yes, you understand the desire perfectly. Thank you so much for your help! I'll look at what you created and compare it to mine to find the error. I really appreciate the time you have spent to help me out. I'll report back what I find (I'm sure I screwed something up!).

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    CharlieGirl
                    last edited by 11 Aug 2010, 15:28

                    Thank you! Your example code showed me that I should separate the material selection from the on-click function - I was trying to do too much at one time. I now have the nested IF for the material selection and the SET function is changing the color shade. That, plus for some reason it seems that I need to have a space between the front and back quote marks and the material names, seems to have fixed the issue. I really appreciate you revisiting my problem for me. Thank you again.

                    1 Reply Last reply Reply Quote 0
                    • C Offline
                      Chris Fullmer
                      last edited by 12 Aug 2010, 01:33

                      Oh good, glad you were able to look through my code and find the help you needed. I find that reading other people's DC code is often tedious...so I'm glad you were able to see what you needed.

                      Chris

                      Lately you've been tan, suspicious for the winter.
                      All my Plugins I've written

                      1 Reply Last reply Reply Quote 0
                      • SJS66S Offline
                        SJS66
                        last edited by 12 Dec 2017, 04:34

                        @chris fullmer said:

                        I went ahead and made a DC that does what you want. The user can choose one of 4 colors from a list. Then upon OnClick'ing on the component, it changes between dark, medium, and light of that color. I'll attach the DC and you can check it out.

                        Chris

                        Not only is he a fellow surfer with a cool hat, he's a sketchup legend. Love ya work mate!
                        Been searching for how to change materials by onclick all day. Doin' my head in.

                        Keep on paddling 😎

                        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