SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

Write article on using lengths in SU #558

Open Eneroth3 opened 3 years ago

Eneroth3 commented 3 years ago

We need an article to explain how to think of units in SketchUp. This can be presented similarly to #549.

SketchUp handles length in a quite different way from other programs. In most CAD programs it seems you are working with numeric values, and it is defined on model level what unit to use when reading those values as physical distances in space.

In SketchUp there is an internal unit, the inch. This can feel counter-intuitive to non-Americans, but also makes sense when you get used to it.

In most cases you don't need to think of what the internal unit is. Distances in space should be represented by the Length class. You can parse string input to it and format values for the UI from it. Generally you can think of the Length as being a physical distance in space, not a number and a unit.

Eneroth3 commented 3 years ago

TT's article is a good start, but we should have this covered by official documentation/help documents.

https://www.thomthom.net/thoughts/2012/08/dealing-with-units-in-sketchup/

kengey commented 3 years ago

Every Cad app I have developed for has internal units. Sketchup has inches, Revit feet, Archicad meters, ... The only difference is that Sketchup uses a separate class, instead of just a number/double, which is especially confusing when serializing them.

Eneroth3 commented 3 years ago

That's good to know. I haven't developed for those but I know Rhino is "unitless" and I think AutoCad is too.

Serializing lengths is definitely worth mentioning in this article!

thomthom commented 3 years ago

Yea, my article is also 8 years old and some of the features I described then as missing is now implemented. But we can lift most of it to a knowledge article in the docs and expand on it with up to date info.

The only difference is that Sketchup uses a separate class, instead of just a number/double, which is especially confusing when serializing them.

That along with the string conversion of Length prints in model units, leading to confusing for some developers as they thing the values printed by Length#to_s represent the underlying data value. We should emphases that Length#inspect dumps the true value as it's stored.