Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now that we have our one picket fence assembled, we can go ahead and add in the intelligence to make those pickets multiply. Now I am working on a copy of the file that we just did. It's called Fence_02 and it's in our Chapter 3 directory. So here I have all the parts basically assembled and ready to go. Now, there is still one little issue and that's that we have a bunch of separate components. We don't have one big component. Let me show you what I mean. If we go to Component Attributes, you will see that every time I select one of these parts, they really are just separate components.
What I need to do is just select them all and make them into one component. I can do that by hitting the G key or by going Make Component. Now, that brings up this dialog box and we can just type in the name of our component, which would be Fencing. So we hit Create. Notice now how the Top and Bottom Rail as well as the Pickets and the EndPosts are now all part of this bigger component called Fencing. So now let's go ahead and make this so when we scale this fence, the pickets multiply. First of all let me show you what happens when you scale it right now.
So I am going to go ahead and scale this. Notice how when I scale it the picket itself scales. We don't have the picket staying the same size. So that's the first thing we need to fix. So I am going to go ahead and undo this and let's go ahead to our Picket option here in our Component Attributes window. If you notice here, we have two values for the size of the picket. One is the Length in Y, which is the depth of the picket. The other is the Width which is the length in X. Right now that's at 5.5 but I don't have that constrained.
So I can constrain that by just going =5.5 and that will force it to always be five-and-a-half inches. Now once I do that notice how this actually turns bold and when something like this is bolded that means it's actually computed or it's actually constrained to a specific number. When things are grayed out such as here, you can actually type in whatever number you want. So now when I scale this, it automatically stays the same size.
So again I am going to go ahead and undo, and now let's go ahead and make this picket multiply as we scale. So we're scaling is actually the master component or the Fencing component here. So for example when I scale this, I am actually scaling this. So what I need to do is actually add in some attributes to Fencing. So I am going to add in a Size attribute and notice when I scale this, this size attribute of length X is what scales.
So that's what we are going to be using to calculate how many pickets we need. So in order to copy the pickets, we need to add in some attributes. So I am going to go down to Picket, hit Add Attribute and let's find the one that says Copies. Click on that and that adds it in. Now we're going to add in one more attribute and that's one that we are actually going to create. It's called Custom Name and we're just actually going to go ahead and enter a custom name and we're just going to type in the word Spacing.
So we're actually creating our own little attribute that we can use to determine the spacing of the pickets. So in this case, let's just go ahead and type in an arbitrary value. We are going to type in 10 or 10 inches between each picket. So now we are going to figure out how many copies we need based upon how wide the fence is. So first thing I want to do is just hit the equal sign here, go in to Copies, and it's going to be equal to the length in X which is scaling it along this red axis, divided by the spacing between this.
So for example in this case, it's 10 inch spacing, so if I had a 120 fence, I would have 12 pickets. So when I do that, what it does now is it actually calculates how many copies I have. So right now it only has 0 copies which means that there is no additional copies of the picket. But if I scale this, notice how this number goes up. Now I have four copies but you can see they are not arranged along the rails. In order to do that, we need to actually calculate the position of each copy.
We can do that by going into the X position of the picket, typing equals and the original value was 0, plus the variable Copy, not Copies plural which is this variable, but a variable called Copy singular and I will show you where we get that in just a second. Just trust me on this. So I am going to go 0+Copy*Spacing. So each picket has an individual number that determines what copy number it is.
So we are going to multiply that by the Spacing. When I hit Enter, there we go! Let me show you where I got that Copy value from. So here we have each of the pickets. Now, if I double-click on this component and click on the actual picket within that component, you can see here under Behaviors, we have Copies and Spacing, which is what we had before. Now, if I click on this other one, the next one, the Copy, notice now we have behavior Copies, we also have an additional attribute put into this one called Copy and that tells us what copy number it is. So this is Copy 1.
This one here is Copy 2, Copy 3. Once you have that, you can multiply that by the spacing to actually have these arrays themselves across the fence. So now if I take this fence and I scale it, you can see now it changes the number of copies as well as arrays them out along the rails of the fence. So now you can see how we can actually array and multiply objects based upon the size of an object.
And this is really useful in any number of different applications. Let's go ahead and continue to refine our fence in the next lesson.
Get unlimited access to all courses for just $25/month.Become a member
102 Video lessons · 5296 Viewers
109 Video lessons · 6852 Viewers
83 Video lessons · 10419 Viewers
56 Video lessons · 12479 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.