DC apparently ignoring End User units and input with units

I’m trying to develop a dynamic component for a model railway harbour wall, where I want to use mm as the model units and as the units for input.

I’ve set the model units to mm with one decimal, and checked Display Units Format in the Model Info/Units window.

I have set all the input parameters to Text, User can edit as a textbox, and Display in End User Model units.

Yet even when I input a length value as (say) 50mm, the component is redrawn as 50cm.

Why? Is this just another of the DC’s numerous irritating bugs? I’ve tried saving the component and reopening it. Makes no difference.


Harbour wall DC.skp (149.2 KB)

Or do I just have to work in cm?

[LATER]
I’ve tried changing the input settings to input as Decimal Number, and Display in mm. Still won’t give me sensible results.

I wanted to make it a dual-unit DC to work in either inches or mm. Seems I can’t even get it to work in one lot of metric units. What am I doing wrong, or expecting wrongly?

Well, curioser and curioser.

I’ve sort of got it to work, using model units of cm.

But the sizes of components simply don’t respect the input sizes either as I drew them, or as defined their size in an input text box and redrawn.

A component that is supposed to be set with a LenX of 1.8cm is drawn as approximately 0.7cm - looks as if the X length input as 1.8 and displayed as 1.8cm in the Component Options is being divided by 2.54 before being drawn.

In Component Attributes, for example, the PilingHeight is shown as 1.9685 (presumably inches converted from 5cm). But the actual height drawn for the component is 1.97cm. This is crazily mixed up.


Harbour wall DC.skp (1.2 MB)

If I want this to work in either imperial or metric units, how on earth do I deal with this?

Yeah, DC gets quite confusing, when dealing with units. Bottomline is that it interprets text standard as inches. Best to toggle all units to inches, for this is SketchUp 's ‘native’ unit.
For changing the units in model info to take place, you would have to ‘reactivate’ the Components Options dialog, it does not ‘redraw’ instantly.

Harbour wall DC.skp (1.7 MB)

Short answer: don’t bother use DCs, it’s not worth it because of the many bugs.

I’m coming to that conclusion, at least when trying to use metric units

A pity. IF they would work, they would be useful.

Indeed! In my opinion DCs had the potential to be the greatest feature of SketchUp but because of how badly it was made it’s very far from being that.

“I’m trying to develop a dynamic component for a model railway harbour wall, where I want to use mm as the model units and as the units for input.”

For model units, I will suggest using “cm” as you have mentioned in your second posting. There is no “mm” option. The units for input by users can be in “mm”. This is the limitation of DC.

image
Units: Centimeters

image

The component option box will display either imperial or metric units, depending on the type of templates used in the preference.

There is a way to toggle between imperial and metric units with the extension from Matt666.

This will only display the different units on the model. The input will still be based on the template that the user selected.

Thanks, all. And particular thanks to @MichaelW for showing that it CAN be done! But even his is drawing the component the wrong size.

I might give it one more go, based on Michaels version.

I’ve posted a feature request to get DCs to work properly and fix the numerous known bugs and other quirks, of which the inconsistency in handling non-inch units is one of the worst.

As per @MichaelW you need to choose centimeters in the drop down units, inches if using inches, but not text, as the value of text is assumed to be in inches
there are scaling issue with your collection of sub components, this probably was produce with the various stretching as changes were made, its good practice to build DCs without changing the original values, always returning to them after testing before adding another formula, otherwise the various subs can get out of sync (out of scale)

I suggest you use groups for the subs, as there is over 1 MB of collected component rubbish for the 150kb component
Can you post a true scaled set of groups without any formula, then I will give it a go using metric

Thank you, Philip.

I will do as you ask later this afternoon or early evening - I’m busy or out until then.

I have been trying NOT to change the original sizes, and several times found I had to Reset Scale for sub components even so. And even after doing that, a Redraw would shrink everything back by the 2.54 factor and draw lengths in cm where the internal DC attribute was (I thought) in inches. It’s been an exercise in frustration so far.

In principle, CAN one write a DC that works equally well in either inches or metric units? If so, do you know if a good example, or better, tutorial? The Help references I found don’t even mention the issue, let alone explain a work around for the quirks.

Sure, it is buggy, but I can’t give up…

It is not the only limitation…, but I can’t give up…

This will not display the units correctly in a metric template , as long as you use text for units ;

and :

You can see this in your picture :
07188ce13d15dbad9dbbdb8113b8bb9d8405aeb4_1_603x500
What really ‘bugs’ me is the PileSpacing dimension… @john_mcclenahan Have you altered it manually ?

I can’t give up…

Try the file I uploaded and, since you are on a Mac and I am not sure if it works directly on Windows ( @pcmoor ?) :

cheers :slight_smile:

No, I hadn’t.

But I HAVE been trying your amended version, and adapted it slightly. I see you have set all the Units to inches, and find it puzzling that it works that way, but apparently it does - with one exception (more later about that).

I wanted to make it scaleable using the scale handles in the X or Z directions, and have succeeded, though with another quirk appearing.

I wanted the X length to be a whole multiple of the PileSpacing, and that was easy, using an example from the Help Centre (https://help.sketchup.com/ko/article/114568) to make a component snap to a specific length.

And I wanted the Piling Height to snap to a whole number of mm. So I tried putting in the formula
PilingHeight = Round(Current("LenZ") - EdgingHeight)
before noticing that you had set all the units to Inches.

This rounded the height to the nearest inch, but displayed it in mm.

So I thought: the units are inches, if I multiply them by 25.4. they will convert to mm, so this ought to do the trick:
PilingHeight = Round(25.4 * (Current("LenZ") - EdgingHeight)/25.4)

And it simply doesn’t work - or else my logic is wrong here?

[EDIT - Yes it is! Should divide before multiply. But when I fix that, it still doesn’t work, and rounds to whole inches, or tenths of inches, If I give it a second parameter to round to one decimal.
PilingHeight = Round((Current("LenZ") - EdgingHeight)/25.4,1)*25.4

When I changed the units for PilingHeight to cm, removed the 25.4 factor, and round to 1 decimal of cm, it DOES work correctly - the PilingHeight correctly snaps to the nearest 1mm.

So I thought: why not make ALL the attribute units into cm?

Tried that - doesn’t work. Changed (for example) PileSpacing to cm. Goes crazy again, and shrinks everything by the (surprise!) factor of 2.54 again.

This is simply nuts.

Anyway. I now have a DC that does what I set out to do, which was to make it easy to explore alternative designs of length, height, and pile size of harbour wall in a small model railway layout being developed by a friend, using inputs in mm.

A VERY BIG THANK YOU MIKE! I’d have given up long since without your help.
Here’s the version I’m going to go with.
Harbour wall DC.skp (2.5 MB)

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.