Decimal Numbers in Dynamic Components

dynamiccomponents
decimals
scientific_notation

#1

For those really technical users that have been around a while:

Is there a way to use scientific notation (e.g., 1000000 = 1e+06) in dynamic components? SketchUp will automatically display large numbers in scientific notation as the result of a match function; however, it doesn’t appear to let the user enter or manipulate numbers using scientific notation.

On a related topic, is there a way to override/work around SketchUp’s rounding to the 6th decimal place?


#2

The display rounding is set in the Model Info > Units panel, Precision dropdown control.

SketchUp itself has an internal limit of 0.001" so I don’t know why more decimal digits would matter. I suppose if you were measuring the diagonal of a 3D volume, and each of it’s sides had dimensions down to the thousandth of a inch, then the actually diagonal length could be more closely expressed to 9 decimal places (or more.)


Now the DC extension is programmed in Ruby, which uses a syntax like “1e+2”.

I just tested using using the picket fence DC in the “Components Sampler” collection, and it took a spacing entry of “1e+2” and changed it to 100" when I hit ENTER.


#3

Interesting… it appears that you can enter scientific notation in the Component Options window, but not in the fields of the Component Attributes window. I just verified this in my model.

My interest in this is using DCs to perform basic material property calculations. On the surface, the calculations are “easy”, but SketchUp’s DC interface and quirks are proving to be very challenging. Trying to avoid Ruby as a matter of convenience, but it’s not easy.

Anyway, thanks for the insight, Dan.


#4

I just entered the following into the “LenX” field for the “Bench” DC:

= 2 * "1e2"
and it resolved into 200"

Adding a sign between the e and the exponent breaks. Basically it looks like the string is run through the standard Ruby to_i method (which ignores non-numerics,) when there is a sign.


So the clunky way, where X is the exponent:

Positive exponent:
= mantissa * "1eX"

Negative exponent:
= mantissa * 1/"1eX"


#5

Ahhh… now we’re getting somewhere. It would have never occurred to me to try math formulas with string text… the 2 * "1e2" seems to work.

I still get an error when just the 1e2 expression is entered in any given field within the Component Attributes window, with or without quotes. Not sure why. When I get some time I’ll fool around with a fresh field or compare/contrast my DC with the “Bench” DC that you used.

As long as there’s some kind of math operator in with “1e2”, then it works… even if there are no other numbers. For example, =“1e2”+ resolves to 100.

I think I can make this work. I’ll need to do some testing and rearranging of formulas to know for sure. The devil’s always in the details…

Thanks again!