Reading Drawing Scale (or Units)

(SketchUp C API)

I have implemented a SketchUp “SKP” file importer for our 3D modelling package, and have discovered that the imported scale is usually correct but is sometimes very wrong.

SUModelGetUnits() returns SUModelUnits_Meters for every model I have tested, and the vast majority of models are imported correctly if I accept this value and use a global scale factor of 1 skp unit == 1 metre.

However, our users have discovered that a small number of SketchUp models are in fact 1 unit == 1 inch.

I have not been able to determine any distinguishing features of these ‘inch’ models.

In all these models, SUModelGetUnits() returns SUModelUnits_Meters, and the “UnitsOptions” SUOptionsProvider returns 0 (Decimal) for LengthFormat and 4 (Metres) for LengthUnit.

It doesn’t matter whether the model is really metres or really inches, I get the exact same results from these calls.

How do I read the actual size of unit that is being used?

The SketchUp application, and all it’s APIs internally uses inches for lengths and coordinates.

Thanks. That is a very… shall we say “surprising” decision.

It’s not very well documented in the SDK, I didn’t find that mentioned anywhere, though I assume it must be somewhere.

I would certainly expect the actual units to be documented on the SUPoint3D page.

I agree. It is documented in the SketchUp Ruby API dictionary, in the Overview for the Length class. viz:

Internally, all lengths in SketchUp are stored in inches. The Length class stores values in inches as well. A number of methods have been added to the Ruby Numeric class to do units conversions.

The SketchUp Ruby API came many years before the C API, so it’s documentation is more robust.

I agree that the description for the coordinates, magnitudes, length, area, and volume values, should explain that they are in inches (and that the internal tolerance is 0.001".)

I opened an API Documentation Parity Issue for the C API in this regard.

1 Like