Dynamic Component supported functions

Following is a list of all functions supported within your dynamic components. Many of these functions are identical to functions found in spreadsheet applications such as the spreadsheet application that is a part of Google Docs.

Math functions

The following functions are for math-related use:

ABS(number)
The ABS function returns the absolute value of number.

CEILING(number, significance)
The CEILING function rounds a number to the nearest integer or multiple of significance. The significance argument is the value whose multiple of ten is the value to be rounded up (.01, .1, 1, 10, etc.).

DEGREES(number)
The DEGREES function converts the number(in radians) to degrees.

EVEN(number)
The EVEN function rounds the numberup to the nearest even integer.

EXP(number)
The EXP function returns e raised to the power of number.

FLOOR(number, significance)
The FLOOR function rounds the number down to the nearest multiple of significance.

INT(number)
The INT function rounds the number down to the nearest integer.

ISEVEN(number)
The ISEVEN function returns TRUE if the number is an even integer, or FALSE if the number is odd. If the number is not an integer, the function evaluates only the integer part of the number.

ISODD(number)
The ISODD function returns TRUE if the number is an odd integer, or FALSE if the number is even. If value is not a number, the function evaluates only the integer part of the number.

LN(number)
THE LN function returns the natural logarithm based on the constant e of the number.

LOG10(number)
The LOG10 function returns the base-10 logarithm of the number.

ODD(number)
The ODD function rounds the number up to the nearest odd integer.

PI()
The PI function returns the value of PI to fourteen decimal places.

RADIANS(number)
The RADIAN function converts the number (in degrees) to radians.

RAND()
The RAND function returns a random number between 0 and 1.

RANDBETWEEN(bottom, top)
The RANDBETWEEN function returns a whole number between the bottom and top number.

Example:

=RANDBETWEEN(1,3)

The previous example returns a 1, 2, 3.

ROUND(number, count)
The ROUND function rounds the number to a certain number of decimal places according to valid mathematical criteria. The count argument is optional and represents the number of the places to round the number. If the count argument is negative, only the whole number portion is rounded.

Example:

=ROUND(1.12789,2)

The previous example returns 1.13.

SIGN(number)
The SIGN function returns the sign of the number. The function returns the result 1 for a positive sign, -1 for a negative sign, and 0 for zero.

SQRT(number)
The SQRT function returns the positive square root of the number. The number must be positive.

SketchUp functions

The following functions are specific to SketchUp dynamic components:

CHOOSE(index,value1,value2, ...valueN)
The CHOOSE function returns a value from a list of parameters at the location of the index value. This function allows you to create a single drop-down list that drives multiple attribute changes at once.

Example:

=CHOOSE(2,"Blue","Red","Green")

The previous example results in "Red."

Use CHOOSE and OPTIONINDEX together as a mechanism to assign different values depending on a user's choice in the Component Options dialog box. For example, if the Component Options dialog box allows the user to choose different materials to assign to a component (and the price changes depending on material chosen), the formula for MSRP might be:

=CHOOSE (OPTIONINDEX("Material"), 100, 150, 200)

The previous example returns 100, 150, or 200 depending on the material chosen in the Component Options dialog box.

CURRENT("attributeName")
The CURRENT function accepts a string name of an attribute, and returns the size or position attribute that the SketchUp user just applied. This function allows you to do validation of Scale tool or Move tool actions.

Example:

=ROUND(CURRENT("LenX")/2)*2

The previous example, when entered into the LenX value field, constrains the component to the nearest width, within 2 inches, after scaling.

EDGES()
The EDGES function returns the number of 'ungrouped' edges inside the component or group that this function is called within.

FACEAREA("materialName")
The FACEAREA method returns the area (in square inches) of every 'ungrouped' face that is painted with the materialName. The FACEAREA method returns the total area of all ungrouped faces when the materialName is not provided.

Example:

=FACEAREA("Oak")

The previous example returns the square inches of Oak material inside the component or group.

FACES()
The FACES function returns the number of 'ungrouped' faces inside the component or group that this function is called within.

LARGEST(value1,value2,...valueN)
The LARGEST function returns the largest of the values in a list.

Example:

=LARGEST(CURRENT("LenX"), 20, 10)

The previous example, when entered into the LenX value field, constrains the component so it cannot be scaled more than the largest of three numbers (either the value of LenX, 20, or 10).

LAT()
The LAT function returns the latitude of the current SketchUp model.

LNG()
The LNG function returns the longitude of the current SketchUp model.

NEAREST(originalValue, value1, value2, ...valueN)
The NEAREST function compares the originalValue with a list of target values, and returns the target value that is closest to the originalValue.

Example:

= NEAREST(CURRENT("LenX"),24,36,48)

The previous example, when entered into the LenX value field, will cause the component to snap to the nearest width of 24,36, or 48 after scaling.

OPTIONINDEX("attributeName")
The OPTIONINDEX function returns the currently selected index from its option list given a string name of an attribute. For example, if an attribute can be 'red,' 'blue,' or 'green,' and blue is the current value, this function returns 2. If no match is found, 0 is returned.

OPTIONLABEL ("attributeName")
The OPTIONLABEL function returns the currently selected label form its option list given a string name of an attribute. For example, if an attribute can be 'Red=red','Blue=blue', or 'Green=green', and blue is the current value, this function returns 'Blue.' If no match is found, an error is raised.

SMALLEST(value1,value2,...valueN)
The SMALLEST function returns the smallest of the values in a list.

Example:

=SMALLEST(CURRENT("LenX"),20, 10)

The previous example, when entered into the LenX value field, constrains the component so it cannot be scaled less than the smallest number (the value of LenX, 20, or 10).

SUNANGLE()
The SUNANGLE function returns the angle (in degrees) between the sun and the current model's North direction.

SUNELEVATION()
The SUNELEVATION function returns the elevation (in degrees) of the sun from the current model's shadow settings. The elevation is defined as the angle between a vector pointing at the sun and the ground plane.

Text functions

CHAR(number)
The CHAR function converts a number into a character according to the current code table. The number argument can be a two-digit or three-digit integer number between 1 and 255 (representing the code value for the character).

CODE(text)
The CODE function returns a numeric code for the first character in a text string. The text argument is the text for which the code of the first character is to be found.

CONCATENATE(text1, text2, ...textN)
The CONCATENATE function combines several text strings into one string. The text1, text2, ...textN arguments are text strings that are combined into one string.

DOLLAR(value, decimals)
The DOLLAR function converts a number to an amount in the currency format, rounded to a specified decimal place. Thevalueargument is the number to be converted to currency. The value argument can be a number, a reference to a cell containing a number, or a formula which returns a number. The decimals (optional) argument is the number of decimal places. If no decimals value is specified, all numbers in the currency format will be displayed with two decimal places. The currency format is set in the system settings.

EXACT(text1, text2)
The EXACT function compares two text strings and returns TRUE if they are identical. This function is case-sensitive. The text 1 and text 2 arguments are the text strings.

FIND(findText, text, position)
The FIND function looks for a string of text within another string. The findText argument is the text to be found. The text argument is the text string to be searched. The position (optional) argument is the position in text where the search starts. The findText argument can be a number or any string of characters. The search is case-sensitive.

LEFT(text, number)
The LEFT function returns the first character (or characters) in a text string. The text argument is the text string. The number (optional) argument is the number of characters to be returned. One character is returned if the number is not defined.

LEN(text)
The LEN function returns the length of a text string including spaces. The text argument is the string whose length is returned.

LOWER(text)
The LOWER function converts all uppercase letters in a text string to lowercase. The text argument is the string to be converted.

MID(text, start, number)
The MID function returns a text segment of a text string. The text argument is the text string. The start argument contains the position of the first character in the text to extract. The number argument is the number of characters to return.

PROPER(text)
The PROPER function capitalizes the first letter in all words of the provided text string.

REPLACE(text, position, length, new)
The REPLACE function replaces part of a text string with a different text string. The text argument is the text string containing the section to be replaced. The position function is the position within the text where the replacement will begin. The length argument is the number of characters in the text to be replaced. The new argument is the replacement text.

This function can be used to replace both characters and numbers (which are automatically converted to text). The result of the function is always displayed as text. To perform further calculations with a number which has been replaced by text, convert it back to a number using the VALUE function. Any text containing numbers must be enclosed in quotation marks so it is not interpreted as a number and automatically converted to text.

REPT(text, number)
The REPT function repeats a text string. The text argument is the text to be repeated. The number argument is the number of repetitions. The result can be a maximum of 255 characters.

RIGHT(text, number)
The RIGHT function returns the last character or characters in a text string. The text argument is the text string. The number (optional) argument is the number of characters to be returned.

SUBSTITUTE(text, searchText, newText, occurrence)
The SUBSTITUTE function substitutes new text for old text in a string. The text is the old text string. The searchText argument is the segment intextto be replaced. The newText argument is the replacement text. The occurrence (optional) argument indicates the number of occurrences of searchText to be replaced. If the occurrence is missing, the search text is replaced throughout.

TRIM(text)
The TRIM function removes spaces in front of a text string or aligns cell contents to the left. The argument contains text string or cell whose contents will be left-aligned.

UPPER(text)
The UPPER function converts a text string to uppercase. The text argument contains the lower case letters you want to convert to upper case.

VALUE(text)
The VALUE function converts a text string into a number. The text argument is the text to be converted to a number.

Trig functions

ACOS(number)
The ACOS function returns the inverse cosine of the number in degrees.

ACOSH(number)
The ACOSH function returns the inverse hyperbolic cosine of the number in degrees.

ASIN(number)
The ASIN function returns the inverse sine of the number in degrees.

ASINH(number)
Returns the inverse hyperbolic sine of the number in degrees.

ATAN(number)
The ATAN function returns the inverse tangent of the number in degrees.

ATANH(number)
The ATANH function returns the inverse hyperbolic tangent of the number in degrees.

COS(number)
The COS function returns the cosine of the number in degrees.

COSH(number)
The COSH function returns the hyperbolic cosine of the number in degrees.

SIN(number)
The SIN function returns the sine of the number in degrees.

SINH(number)
The SINH function returns the hyperbolic sine of the number in degrees.

TAN(number)
The TAN function returns the tangent of the number in degrees.

TANH(number)
The TANH function returns the hyperbolic tangent of the number in degrees.

Logical functions

The following functions are for math-related use:

AND(logicalValue1, logicalValue2, ...logicalValueN)
The AND function returns TRUE if all arguments are TRUE. If any element is FALSE, this function returns the FALSE value. The logicalValue arguments are conditions to be checked. All conditions can be either TRUE or FALSE.

FALSE()
The False function sets the logical value to FALSE. The FALSE function does not require any arguments.

IF(test, thenValue, elseValue)
The IF function identifies a logical test. The test argument is any value or expression that can be TRUE or FALSE. The thenValue (optional) is the value that is returned if the logical test is TRUE. The elseValue (optional) is the value that is returned if the logical test is FALSE.

Example:

=IF (5=5, 1, 0)

The previous example returns a 1 if the test (5=5) is TRUE. Otherwise, the function returns a 0.

NOT(logicalValue)
The NOT function reverses the logicalValue. The logicalValue argument is any value to be reversed.

OR(logicalValue1, logicalValue2, ...logicalValueN)
The OR function returns TRUE if at least one argument is TRUE. This function returns FALSE if all the arguments have the logical value FALSE.The logicalValue arguments are conditions to be checked. All conditions can be either TRUE or FALSE.

TRUE()
The TRUE function turns the logical value to TRUE. The TRUE() function does not require any arguments.

OnClick functions

ALERT("message")
The ALERT function displays the value of the message in an alert box.

Example:

=ALERT("You Clicked Me!")

The previous example displays an alert box with the phrase 'You Clicked Me!,' when inside the ONCLICK attribute.

ANIMATE(attribute, state1, state2, ... stateN)
The ANIMATE function starts an animation that will change the value of the attribute to the next value in a list of parameters every half a second.For example, if the ONCLICK attribute contains ANIMATE("X",0,100), and the user clicks on the component, the component would animate the value of the 'X' attribute between 0 and 100. A subsequent click would animate back to 0 from 100.If more than two animate states are passed, then the value will toggle between them in order. So, if the ONCLICK attribute equalsANIMATE("ROTZ",0,-130,10,100) the animation would go through each of the 4 values with each click.

This function animates with defaulteasing. Easing is the speed of the animation (on a scale of 0 to 100, 0 being fastest). Easing is represented by two numbers. The first number (easein) identifies the speed at the start of the animation. The second number (easeout) identifies the speed at the end of the animation. Default easing is 0,100 (animation starts fast but slows down at the end).

ANIMATESLOW("attributeName", state1, state2, ... stateN)
The ANIMATESLOW function does the same thing as animate, but slower (one second).

ANIMATEFAST("attributeName", state1, state2, ... stateN)
The ANIMATEFAST function does the same thing as animate, but faster (a quarter of a second).

ANIMATECUSTOM("attributeName", time, easein, easeout, state1, ...stateN)
The ANIMATECUSTOM function does the same thing as animate, but with an arbitrary time with easing. Refer to the ANIMATE function for information about easing.

GOTOSCENE("sceneName", time, easein, easeout)
The GOTOSCENE function moves to a scene identified by a name or number. Refer to the ANIMATE function for information about easing.

REDRAW()
The REDRAW function redraws the component that contains this function.

SET("attributeName", state1, state2, ...stateN)
The SET function sets a given attribute to the next state in a list.

Was this article helpful?