Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In addition to being able to type in numbers for values, we also want to be able to select them from a list so we can add things like presets, sizes and colors. Things like furniture, like this couch, can usually come in different sizes, such as small, medium and large. Now we can actually give the user the option of selecting a different sized couch, just by giving them a pull-down menu in their Component Options window. So, I'm working with a file here called Sofa_02, which is a file that we used in the last lesson.
So I'm going to go ahead into Dynamic Components and select Component Attributes. Now you'll see we have all of the same attributes we set in the last lesson. We have Position as well as the custom attributes such as Price. Now, typically, we don't want to give the user the option of changing the position of the couch through a menu. They can just use the Move tool. So I'm going to delete that. So I'm going to go ahead and select that, hit Delete and say OK and do that for both of these. So now that I've cleared that out, if we look at our Dynamic Components' Component Options window, you'll see that basically all we have is a price of the couch.
Now let's go ahead and add in a size. Now we can create different sized couches by basically stretching it along this green axis, which is our Y axis. So what we want to do is add in an attribute here called length Y or LenY. You could see that's green, which matches the axis that we want to stretch it on. All we really have to do is just type in a number such as 80 and you can see the couch stretches. Or if we type in a larger number, you can see it stretches bigger.
So we can use this as the basis for creating sizes for the different couches. Now we do this by going into our Details window. So let's go ahead into Details and we have to have a display rule. But what we want is we want users to be able to select that option from a list. So let's go ahead and select that and then just add an option. So we can type in our first size, which is 80. If we hit Enter, notice how it enters it for the Value field. Now this List Option is actually the name we give the user. The value is the actual number that's plugged in, the actual amount.
So let's go ahead and type in one for another one. Let's say we want a 96-inch wide couch and we want another big couch. Let's say 108 inches. So once we hit Apply, notice what we have. Let's go ahead into our Component Options window and you can see we have a second value here called Length of Y. Well, that's not all of that descriptive but let's see how this works. We can say 80 and hit Apply. You see we have a 80-inch couch, a 108-inch couch or a 96-inch couch.
Well, we really want to make this a little bit more user-friendly. Length of Y isn't all that descriptive and the size of the couch in inches isn't as descriptive as we can be. So I'm going to close this. Let's go back to our Component Attributes window and let's go into Details again. So for the List Options, all we have to do is change the name here, Small, Medium and Large. Then for the Display label, instead of Length Y, let's go ahead and type Size.
So once we hit Apply, we can go back into our Component Options window. You'll see now we have a sofa that is small, medium and large. Now, one of the things I'm also noticing here is that well, when we have different sized couches, the price itself is actually going to change. So what we can do is calculate a new price based upon the size of the couch.
We can do it a number of different ways. Let me show you one really simple way. And that's to basically take the price of the couch, which equals $459 and that's for the small couch. So we divide it by 80 and that gives us a price per inch. Then we just multiply that by the total number of inches, which would be Length of Y. We hit that and then basically, depending upon the size of the couch, it will calculate a price. So let's go back into Component Options.
Let's see how that works. So when I do small couch, it's still $459. But if we do medium or large couch, it will go ahead and scale it accordingly. Now this formula is actually pretty crude. It prices the couch by the inch. Now, typically, couches aren't priced that way. They really have set prices based upon the small, medium and large sizes. So we can actually do a little bit more sophisticated math using functions.
Let me show you how that works. So what I'm going to do is I'm just going to go ahead and go back to the base price of the couch. It's going to be =459+ and then we have to see what size the couch is. Well, we can use what's called an if-then statement. If we go into Functions here, you can see we actually have spreadsheet functions, very similar to functions you find in Excel or any other type of spreadsheet. If you scroll down, you'll see we actually have all sorts of different functions from square roots to SketchUp functions, which allows you to determine things about geometry of an object, but the ones we're looking for are logical functions.
So I want to have an if-then statement. So I'm just going to go ahead and click on this. What that does is actually just gives us a reference here. I want to make sure my cursor is here, 459+, and then I'm just going to hit Insert, plus the result of this if-then statement. Well, what are we testing? Well, we're going to test to see if the LenY=96, which is our medium sized couch. If it is, we're going to add 50 bucks to the price of the couch.
If it's not, we're going to add nothing to the price of the couch. So let's take a look at this again. So, 459, the base price of the couch, plus if the length is 96 inches, then we're adding 50 bucks. If not, we're adding nothing. So let's see how that works. We're going to go ahead into our Dynamic Components' Component Options. So now let's go to a small couch. Hit Apply. That's $459. Medium couch should be 459+50, which is 509, and that works.
Let's go to the large couch and you'll see well, it goes back to 459. Well, what we have to do here is add in one more if-then statement. What we're going to do is go ahead and add in a plus sign here, and we're going to do another if-then. So I'm just going to keep this one up, hit Insert. Let's go ahead and do this one more time. So if, okay, test. So if LenY=, and our largest size couch is 108, then we're going to add $100 to the price rather than 50.
If it's not equal to that, well, we're going to add nothing to the price. So now that we have all of those, we should have an accurate pricing model. So again, Dynamic Components > Component Options and let's see how this works. Well, obviously it's already calculated. We have a price of 559 for the large sofa, the small sofa is 459, the medium sofa is 509. So as you can see, we can get very sophisticated behaviors just through simple formulas.
So what we've done is we've added in a selection list that allows us to select a small, medium or large couch, and now, using if-then statements, we've actually calculated accurate prices for the couch, depending upon the size. So as you continue we can get very sophisticated in how our dynamic components behave and report data back to the user.
Get unlimited access to all courses for just $25/month.Become a member
100 Video lessons · 11561 Viewers
56 Video lessons · 10557 Viewers
83 Video lessons · 8414 Viewers
109 Video lessons · 3945 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.