DC - Stick to nearest in cm units not working properly


#1

Following a simple DC example from the Sketchup Help Center at:
https://help.sketchup.com/en/article/115749

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

I can’t get a DC to stick to cm values of 10, 20, 30 for example. I’ve set all units to cm everywhere possible, in the model and within each attribute. In order for the box to stick to the correct cm values I have to stretch it to the inch values… (see attached).

Is this a known bug? Is there a way around it?

stick_to_nearest-cm_issue.skp (266.1 KB)


#2

DC-s seem to have many related issues where imperial units creep in. For instance, see what happens if you set a length attribute to display as a decimal number in the Options dialog.

Have you tried typing in the unit string “cm” after your numbers in your formula?
Is the “display units format” box checked in ModelInfo>Units?

Anssi


#3

Setting to display as decimal makes no difference…
“display units format” is checked…


#4

No, I didn’t in fact even suggest that - it was an example of another glitch.

Where are you putting the formula? I tried it, and if i put it directly into the LenX attrubute I get a callback error message. If I create a custom attribute, put the formula inside and make the LenX attribute to reference it, it works.

Anssi


#5

See the file I uploaded in the first post. The formula is in the LenX attribute - no errors given.
I’ve tried referencing in and out… nothing seems to work for me. Could you upload your file?


#6

I also tried the SKP you posted and it worked. Both in it, and my own test, for some obscure reason, you must really exaggerate your use of the Scale tool to make the length stick to the largest option. Yes, it might again be a hidden cm/inch issue.

Anssi


#7

It seems to be referencing the “current” length in inches… and then calculating the “nearest” in cm… That’s why when you stretch to 30 inches, it falls back to 30cm… or 20 inches to 20 cm…


#8

Yep, it looks like a bug to me.
I think I’ve found a “workaround”… “Force” the LenX units to Inches, and display them as what ever you want the user to see… and one must remember they are in inches when referencing to LenX later on…


#9

It works as expected too if you set the internal units of the DC to Inches and type the lengths in your option attributes with the unit included (or, if the options are to be set by the user, set the input fields on the Options dialog to use metric units or “End user model units”.

Anssi