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

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

Postby CharlieGirl » Wed Jul 14, 2010 3:46 am

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!
0

CharlieGirl 
 

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

Postby CharlieGirl » Fri Aug 06, 2010 6:35 pm

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!
0

CharlieGirl 
 

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

Postby Chris Fullmer » Fri Aug 06, 2010 9:12 pm

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
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

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

Postby TIG » Fri Aug 06, 2010 9:43 pm

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... :geek:
0
TIG
User avatar
TIG 
Global Moderator
 

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

Postby CharlieGirl » Tue Aug 10, 2010 8:47 pm

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!
0

CharlieGirl 
 

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

Postby Chris Fullmer » Wed Aug 11, 2010 12:28 am

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
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

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

Postby Chris Fullmer » Wed Aug 11, 2010 1:32 am

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
1
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

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

Postby CharlieGirl » Wed Aug 11, 2010 2:14 pm

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!).
0

CharlieGirl 
 

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

Postby CharlieGirl » Wed Aug 11, 2010 4:28 pm

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.
0

CharlieGirl 
 

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

Postby Chris Fullmer » Thu Aug 12, 2010 2:33 am

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
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

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

Postby SJS66 » Tue Dec 12, 2017 5:34 am

Chris Fullmer wrote: 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 :fro:
0
User avatar
SJS66 
Premium Member
Premium Member
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Dynamic Components

Who is online

Users browsing this forum: No registered users and 1 guest

Visit our sponsors: