Making a Resizable Dynamic Component
Next to changing colors and materials, one of the most popular options you can provide in a dynamic component is the ability to resize it. Resizing comes in handy for everything from doors and windows to outdoor furniture—like a simple bench that can change colors. Sure, you can resize the bench using the Scale tool, but look what happens. As it is, the bench is 6 feet long. Suppose you want it to be 3 feet long. Go ahead—give it a try with the Scale tool (Figure 14-14). Resize the bench along the red (X) axis, and the bench seat and the support between the two legs do just fine, but the bench legs get squished. Instead of nice sturdy 2-inch legs, your bench has thin, spindly legs, out of proportion with the rest of the model. So when you make a component that designers can resize, you need to pay attention to the proportions. You need to constrain some of the dimensions, while permitting others to change. That's exactly what you learn to do in this next exercise.
Figure 14-14:
Use the Scale tool to turn a 6-foot bench into a 3-foot bench, and it distorts some of the bench parts. These formerly 2-inch bench legs are now only an inch thick.
Figure 14-14:
Use the Scale tool to turn a 6-foot bench into a 3-foot bench, and it distorts some of the bench parts. These formerly 2-inch bench legs are now only an inch thick.
In this example, you give designers the option to choose sizes of 3 feet (36 inches), 4 feet (48 inches), 5 feet (60 inches), and 6 feet (72 inches). You constrain the attributes of all the entities that you don't want to change—like the legs. You manage all of this in the Component Attributes window, in much the same way you worked with the color and material attributes in the previous section.
To start the process, follow these steps to change the attributes to resize the bench:
1. Select the bench_dc component and then choose Window ^ Component Attributes.
The Component Attributes window opens displaying the previous Material attribute you created in the steps starting on page 460. At the top you see the attributes for the bench_dc component. Below you see the four subcomponents that are inside of the bench_dc component: Bench Seat, Bench Support, and two Bench Leg components. In this exercise, you change attributes for the main component and the subcomponents.
2. In the Component Attributes window, under bench_dc, click the "Add attribute" button.
The Component Attributes window changes. On the left, your cursor automatically appears in the Enter Name box, which is used for creating custom attributes. You're not creating a custom attribute, so don't type anything. To the right, the Attribute List shows the standard attributes, including the Size attributes: LenX, LenY, and LenZ.
3. In the Attribute List, click LenX.
The Component Attributes window changes to accommodate the new attribute LenX, as shown in Figure 14-15.
Tip: Make sure you click the LenX attribute, not the X attribute. The X, Y, and Z options control the position of the component, not the dimensions.
4. To the right of the word "LenX", click the Details button (it looks like an arrow with a menu pasted on top).
The Component Attributes window changes to show the settings related to the LenX attribute. At the top of the window, you see the name bench_dc!LenX. Below it are two drop-down menus: Units and "Display rule". The Units is set to inches, so you don't need to change it.
Details button
Details button
Figure 14-15:
As you add new user-changeable attributes, the Component Attributes window keeps track of them all. Here the window displays the new LenX attribute. As you see in this project, you can modify attributes for nested components, too.
Sub-components
Figure 14-15:
As you add new user-changeable attributes, the Component Attributes window keeps track of them all. Here the window displays the new LenX attribute. As you see in this project, you can modify attributes for nested components, too.
Sub-components
5. From the "Display rule" menu, choose "Users can select from a list".
The Component Attributes window displays the "Display label" text box and a table where you add option names and values.
6. In the "Display label" box, type Bench Length.
SketchUp displays this attribute name to designers who use your component.
7. In the table, click the "Add option" button.
A new row appears in the table, and your cursor is automatically placed in the box under the List Option heading. Here's where you provide the name for the option that designers see. Each option is made up of two parts. The List Option is the name that designers who use your component see on a drop-down menu. The Value is the value that SketchUp applies to some attribute of your dynamic component. In this case it's the LenX attribute, which is the length of the component along the red axis.
8. Type 3 feet and then press Tab.
When you press Tab, the cursor moves to the next box under Value. Here's where you supply the value that's applied to your component.
9. Type 36" and then press Tab.
You just programmed your component so that when designers select the "3 feet" option, the value of LenX (the length of your bench) changes to 36 inches. When you press Tab, a new option row appears, and you can add another option to the list. If you press Enter (Return), SketchUp assumes you're done and doesn't add another option.
10. Repeat steps 8 and 9 to create options for 4 feet, 5 feet, and 6 feet.
When you're done, the Component Attributes window looks like Figure 14-16.
11. Click the Apply button.
SketchUp saves your changes to the LenX attribute. The Component Attributes window changes to show the components in bench_dc.
You're not done with this component, but now's a good time to save and test it. Open the Component Options window, and you see exactly what the designers who use your component see (Figure 14-17). Click the Bench Length menu, and test the different options. You have to click the Apply button for the changes to take place. You haven't constrained the Bench Leg dimensions, so the resize squishes the bench legs as it did when using the Scale tool.
Post a comment