Using Negative Numbers in Dynamic Components

As a relative newcomer to SketchUp Pro I'm constantly running into issues and questions that I can't resolve or answer myself. In such cases I jump back into Sketchup courses on Lynda.com or find an appropriate video on YouTube.

In a recent project, involving cabinets, drawers and doors, I wanted to use Dynamic Components to animate the drawer and door. I followed along on the Lynda.com course SketchUp Pro: Tools and Techniques - Creating Dynamic Components - Adding Interactivity: Motion but kept running into issues not covered in the tutorial.

Here's what was happening. I'd add the interactivity, via the Component Attributes panel, after clicking on the drawer and door components, with the 'Interactivity' tool, they would open but not close. See the video below.

Note: this relates to Sketchup Pro on an iMac (I cannot say what the results are on other OS platforms)

Also after clicking on the components the Component Attributes panel showed different entries from the settings I'd created.

 
Before interaction

Before interaction

After interaction

After interaction

 

After interacting with the model the RotZ values had changed.

The only thing I was doing different, to what the Lynda.com tutorial was teaching, was the fact that I was using a 'Negative Value' for the open position.

So after a bit of searching and reading through various forums I came across a post that recommended using quotes around the "attribute" value.

When you are creating your 'onClick' behaviour the function that you load has quotes around the attribute word. Normally to replace that value you would just select the whole value, "attribute", and then click on the position value (in this case Y) to automatically update it.

 
Select attribute and click on Position.

Select attribute and click on Position.

Position has been automatically replaces, "attribute". Then I've added in the original position and the onclick position

Position has been automatically replaces, "attribute". Then I've added in the original position and the onclick position

 
Note: If you have selected the whole "attribute" (including quotes) the quotes are removed.

Now this doesn't matter if you are using positive values. The interaction will happen regardless of the quotes. 

However if you are using negative values then you will see the same open interactivity without the close interactivity.

So after reading that I needed to use quotes if I was using negative values I proceeded to type in the quotes around the Position value. I selected my interactivity tool (Menu/Tools/Interact) and clicked on the drawer.

To my surprise nothing moved instead I got the following error message;

 
Error message after adding quotes to the "Y" value

Error message after adding quotes to the "Y" value

 

After a bit of head scratching and Googling, I determined that, the “Invalid entity to animate” error was caused by smart quotes, which are enabled by default on OS X.

They are called “smart quotes” because the OS selects when to use the left quote and when to use the right quote by context rather than having user type the two different characters. The left quote and right quote are different unicode from the straight quote and are not recognized by SketchUp’s parser, hence the error.

In order to resolve the issue you need to turn off smart quotes in System Preferences/Keyboard/Text/uncheck “Use smart quotes and dashes.”

 
Uncheck 'Use smart quotes and dashes'

Uncheck 'Use smart quotes and dashes'

 

To ensure that you are using the correct quotes;

1. delete any inserted functions,
2. close and re-open the Components Attribute window
3. re-enter the functions

Using the correct quotes the negative values work as expected as per the video below.

 

As a side note the standard “ANIMATE” command is very fast. If you want your animation to be smoother and more natural looking, choose “ANIMATESLOW” or alternatively “ANIMATECUSTOM”.

Download the .skp of the cabinet using the Slow and Custom functions.

cheers,

Tony