A Simple Smart Object

How do I use attributes to make my shelves the same, fixed depth?

If you have a dimension that you want shared, I recommend creating an attribute for it, giving it a value and locking it down. You can then refer to it in all the shared places. You could use this technique, for example, to give all your shelves the same depth.

Before we begin, please note that, in the paragraphis that follow, I will assume that your shelves all face the Front view. If this isn't true, I highly recommend rotating your bookcase so that they are. Doing so is relatively straightforward. If your bookcase and shelves are already grouped, select the group. If not, select all the bookcase objects and use the Layout inspector to group them, after which the newly-created group will be selected. Now, in the View controls, switch the view to Top and use the Layout inspector to rotate the bookcase group so the shelves are facing the Front view.

Make sure the checkbox labeled Auto-switch is checked at the top of the Inspectors window. In your drawing, click on any object or dimension. In the inspector window, click on the popup menu near the top labeled Inspect Something Else and select the first item (which will be the name of your design document -- Untitled if you haven't saved your file yet). You will now be in the Object inspector, inspecting the outermost group. This is where we want to create a new attribute.

At the top of the Object inspector, click on the button that says Add Authored Attribute to Document. This will switch the inspectors window to the Attribute inspector. Fill in the field near the top with "ShelfDepth" and the Value field with a good value. Let's say that you want your shelves to be nine inches deep, so type in a nine followed by a double quote. Hit return. Enable the Lock checkbox, to the immediate left of the Value field. Your attribute is now created, set with a value and locked. Now, let's use it.

Click on one of your shelves in the drawing. In the Object inspector, enable Expressions. In the table, figure out which row corresponds to the width of your shelf plank (if your shelves face the Front view, then you want the row labeled Depth). Double-click in the Expression column of this row. This lets you edit the shelf attribute's expression. Type in "sh" and notice that Design Intuition has entered the name of your new attribute, "ShelfDepth," for you. Hit return.

You can do this same thing to all your shelves. Their depth will never again change.

Actually, I want my shelves to grow and shrink like your Smart Objects. How?

That's quite easy. We're going to add a few more attributes, first and then use them in several places. Instead of describing each one, I'm going to list them in a table.

name Refers to Attributes in Object value locked? expression locked?
BackThickness no 1/4" yes no
BackInset no 1/2" yes no
ShelfHeight no 3/4" yes no
PlywoodThickness no 3/4" yes no
ShelfDepth yes no Depth - BackInset no

Add the first two of these attributes (BackThickness and BackInset), in the same way that you added the one above, using values from the table above. Then switch to the Details View and click on the row labeled ShelfDepth. In the Attribute inspector, check the checbox labeled "Searches Object" and replace its expression with "Depth - backi" and notice that Design Intuition will replace the "backi" with "BackInset." Without doing anything more, the depths of all your shelves will correctly adjust when you resize the outermost group.

Now for the fun part. Add the next two attributes (ShelfHeight and PlywoodThickness), as before. In your drawing, select one of the shelves. This switches the Object inspector to inspect this shelf.

Double-click on the expression in the row labeled Left, and erase the expression. Replace it with "Left + ca" and notice that Design Intuition will replace the "pl" with "PlywoodThickness." Type Return. Double-click in the row labeled Right and replace its expression with "Right - ca" and type Return. Finally, double-click in the row labeled Height and replace its expression with "shelfh" and type Return.

Repeat these same three steps with each of your shelves. They will now grow and shrink appropriately when the outermost group is resized.

What are the guidelines you followed when you chose those attributes?

Yes, sure. But I need to use the concept of Refers to Attributes in Object. I recommend reading about it before continuing.

Guideline One, "Centralize" You want to place all your attributes in the containing group (typically the outermost group), where all the contained objects can find them. When Design Intuition resolves an expression, it looks for numbers, operators and the names of attributes. When it figures out which attribute corresponds to each name, it first looks in the group (which contains the object which owns the attribute whose expression it is resolving -- whew!). Note that, if you check the box labeled "Refers to Attributes in Object," Design Intuition will first search the object which owns this attribute and then search the containing object. Either way, by placing attributes in the containing group, they are centrally and quickly located.

Guideline Two, "Outside-In" When you resize the outermost group, you are controlling its position and dimension attributes. Changes in these attributes, in turn, will directly effect the objects contained in the outermost group, because of the expressions in those contained objects' attributes. Ack, what a sentence. Let me say it a bit differetly.

Inside Design Intuition, whenever an attribute changes (in our case, the width of the outermost group), this change is communicated directly to any attributes that are affected by this change. What attributes are those? Well, any attribute whose expression refers to the-attribute-being-changed, which turns out to be almost all attributes.

I call this communication activity "propagation." In this example, it flows from the outside in, i.e., from the [outermost] containing group, [indward] to it's contained objects, and if any of those is a group, inward from there. Hence, "The Outside-In Guideline."

All of this leads up to a way of thinking about your expressions. Positions of objects ought to have expressions that refer to the containing group. This lets changes in the group directly affect positions. More generally, when your outermost group is resized, everything else inside it will respond well.

Guideline Three, "Self-Reference" If an attribute has the Refers to Attributes in Object checkbox checked, and Design Intuition resolves all of the attribute names in your expression to other attributes in the object which owns this attribute, then this new guideline applies to those other attributes. They must follow the Outside-In Guideline.

What happens if I break these guidelines?

To give you an example of something which doesn't follow guideline two, suppose we make the width of the shelves a constant (by locking its value) and make the outermost group's width depend on the shelf width. Because the outside (outermost group) depends on the inside (the shelf), propagation is flowing from the inside to the outside. Consequently, you would have to grab the shelf and resize it to get the outermost group (the bookcase) to change. This would feel unnatural and unintuitive. It would have to be explained to people who use the bookcase as a Smart Object.

Why doesn't Design Intuition take care of this for me?

Great question. At some point, Design Intuition will have much better support for this kind of designing. As you may have guessed, doing that for 1.0 would have been quite a feat: Not even the multi-thousand-dollar CAD software tries to pull that off.

Okay. Now, I'd like to see your bookcase Smart Object explained

To do that, we need a few more attributes:

name Refers to Attributes in Object value locked? expression locked?
VerticalKick no 4" yes no
HorizontalKick no 3 1/2" yes no
DadoDepth yes no PlywoodThickness / 2 yes

The left side of our bookcase gets altered so that the expression for Top is Top, Bottom is Bottom, Front is Front, Back is Back, Left is Left, Depth is Depth and Height is Height. This might seem odd -- setting "a thing" to "a thing" seems like it's referring to itself. However, because Refers to Attributes in Object is not enabled for these attributes, we're setting "a thing" to "the containing group's thing." This "glues" the side pieces to our bookcase to the sides, top, bottom, etc. of the outermost group. This will be important when our design is saved into the Library and then used from there.

Two attributes remain, Width and Right. The expression for Width is PlywoodThickness and Right gets Refers to Attributes in Object enabled and is "Left + Width." You'll want to enable Refers to Attributes in Object before altering the expression. All of these expressions (except the last one) can be edited directly into the Details or the Object inspector. The expressions for the right side of our bookcase is the same except that Right is Right and Left gets Refers to Attributes in Object enabled and is "Right - Width."

All the remaining four pieces are let into the sides, so for all of them: Left is "Left + DadoDepth," Right is "Right - DadoDepth," and Width gets Refers to Attributes in Object enabled and is "Right - Left."

For the top and bottom pieces, Front is Front and Back is Back, Height is PlywoodThickness, Depth is Depth. For the top piece, Top is Top and Bottom gets Refers to Attributes in Object enabled and is "Top - Height." For the bottom piece, Bottom is VerticalKick, to lift it off the floor, and the Top gets Refers to Attributes in Object enabled and is "Bottom + Height."

For the kick, Bottom is Bottom and Depth is PlywoodThickness, Front is HorizontalKick, Height is "VerticalKick + DadoDepth," Top gets Searches Object enabled and is "Bottom + Height," and Back gets Refers to Attributes in Object enabled and is "Front + Depth."

For the final pieces, the back, Depth is BackThickness, Front is BackInset, Bottom is "VerticalKick + DadoDepth," Top is "Top - DadoDepth," Back gets Searches Object enabled and is "Front + Depth," and Height gets Searches Object enabled and is "Top - Bottom."

You should now be able to select the outermost group and as you resize it, all the components of the bookcase should reposition and resize appropriately.

Why do all nine attributes of every piece need attention? Isn't that redundant?

Clever of you to notice. The reason has to do with speed. Rendering in the 2D views uses values from six of these nine attributes, whereas rendering in the 3D views uses values from a different set of six. Between them, all nine are used. It worked out this way because of peculiarities inherent in each of the rendering mechanisms.

 

Buy, now!