Units in a SketchUp model and faces with short edges

Hi,

I was doing some work on the Rhino to SketchUp export plugin recently and I noticed a TODO I had made about setting the units in the SketchUp file if Rhino’s units were one of the SUModelUnits enums (setting a scale factor based on our units to inches otherwise). I see a SUModelGetUnits function in the SDK but no SUModelSetUnits, so unless the Rhino model was in inches I’m always scaling. How do you set the unit system on a SUModelRef? Just for grins I tried changing the unit system in SketchUp 2016 too but couldn’t figure that out either. Are you guys just inches now and SUModelGetUnits is for legacy files?

The reason I even started looking at the unit system again is I noticed that edges smaller than about .002 inches don’t get turned into faces right when I bring a model exported from Rhino into SketchUp. It’s fine to have a component with a scale transform that makes it smaller but not if the geometry itself has edges shorter than that. Is that supposed to happen? Is there a certain length, under which stuff doesn’t work right? I was going to pop up a message box to warn users when they have geometry that might not open right in SketchUp but I wanted to make sure I got it right.

Tim

Forgot to mention. Looks like the version of the SDK we’re using (based on the .dll version info) is 16.0.19912.0.

I’d like to resurrect this thread. Can we please have a simple means of setting the unit system on the model in C API? The analog of SUModelGetUnits but for setting (ie. SUModelSetUnits). Is this hard to do? If there is no other way than using the options manager stuff, can you please give us a clear example in C, or point us to one if one already exists. I just downloaded SDK_WIN_x64_2021-0-339 and I can’t find anything in the samples.

Thanks.

Tim

Wasted time ...

ALL SketchUp (and .skp file) internal coordinates are in inches. The units settings affect only display of coordinates, lengths, areas and volumes in the GUI, and some of the formatted string output methods of the APIs.

Yes, This is the small face scenario. SketchUp was designed to model buildings and so has an internal tolerance of 0.001". (So coordinates closer than this will get merged.)

There is the “Dave method” in which a component is drawn at a larger scale, and then an instance is placed in the model scaled down to actual size. This is usually done manually, but could also be done programmatically.

There are countless forum posts about this in the main SketchUp modeling categories.

More wasted time ...

I think that this was an early convenience “shortcut” function (perhaps used by the online 3D Warehouse to quickly get the user units of a model for online display.)

There is an issue in that it uses a “forgotten” enum that was not updated when yards was added as a new user unit.

I do believe that querying the options manager should be safer as it uses it’s own enum for the units.

I filed an API Issue on this a year ago

enum SUModelUnits lacks a member for the new yards unit · Issue #442 · SketchUp/api-issue-tracker · GitHub

… in which @tt_su said …

I’m leaning towards deprecating SUModelUnits and SUModelGetUnits as it appear to be redundant. Don’t want to bloat SUModel* further by adding functions for area and volume units. SUModelGetUnits is even asymmetrical, no setter.

If you have thoughts @tim, please add them to the open issue, and / or file a specific request in the GitHub API tracker for the model level setter method(s). But, I can say right now that it is unlikely to happen as there are multiple options that must be set in the correct combination in order to set the user units. (Basically the settings must match a valid setting in the GUI.) The Units Options manager can do this.

Example: When LengthFormat is Engineering, the LengthUnit must be Feet.

See also …

What's the right way to set unit of model with C API? - #4 by DanRathbun

Hi Dan,

I don’t care about the edge stuff. I handled that a long time ago. Not long after I got crickets from my initial post.

Here’s what I can tell you is fact because I can demonstrate it. If you make a model in SketchUp with the units set to meters, for example, and make a box that is 3x4x5m. Save that model as a .skp file. You can open that file in Rhino and confirm that the units were set to meters and the box is 3x4x5m. I know that it is using the unit system from SUModelGetUnits because I wrote the Rhino plugin that opens SketchUp files.

What I currently do on export is scale the model from whatever unit system Rhino is using to inches because there is no way to set the model’s unit system, with the SDK, that I understand. I’d like the user to be able to make a model in Rhino using a unit system that SketchUp supposedly supports:

@enum SUModelUnits
@brief Units options settings
*/
enum SUModelUnits {
SUModelUnits_Inches,
SUModelUnits_Feet,
SUModelUnits_Millimeters,
SUModelUnits_Centimeters,
SUModelUnits_Meters
};

so that a user can roundtrip a SketchUp file and preserve the units instead of having them converted to inches.

Tim

I never saw the original post. And I am bowing out of this topic now. All I will say regarding this …

… is that again, everything internally in SketchUp, LayOut and their file formats is in inches.

I humbly apologize. I just looked at the import code. While I do get the unit system from the file using SUModelGetUnits, I am scaling the geometry with a unit scale from inches to whatever the unit system SUModelGetUnits returns. So you are right, inches internally regardless of the unit system.

I guess I’ll let this rest. However, if the SkectchUp API devs ever do any unit system updates can you please let me know. I guess I’ll get notified via email if you reply to this forum post.

Tim

That would be a major change. It would certainly be messaged if that ever happened.