Scale geometry when importing shapes #12

Closed
opened 2024-08-09 16:37:41 +02:00 by Hombre57 · 7 comments
Collaborator

The standard states in §4.3.3 that size and coordinates are in meters :

 4.3.3 Standard Units

VRML provides no capability to define units of measure. All linear distances are assumed to be in meters and all angles are in radians. Time units are specified in seconds. Colors are specified in the RGB (Red-Green-Blue) color space and are restricted to the 0.0 to 1.0 range.

However some software exports the geometry in their current base unit, e.g. millimeter. I'd suggest to add a scale parameter in the import file selector.

There's two options for the implementation :

  1. use this value to change the matrix of the object, i.e. set it's scale value for each axis
  2. use this value to compute it's new size and position and leave the scale matrix to 1.0

I can produce a patch for any of these solutions. Which one is preferable ? The first solution is the least invasive.

[The standard](https://graphcomp.com/info/specs/sgi/vrml/spec/part1/concepts.html#GeometryNodes) states in §4.3.3 that size and coordinates are in meters : ``` 4.3.3 Standard Units VRML provides no capability to define units of measure. All linear distances are assumed to be in meters and all angles are in radians. Time units are specified in seconds. Colors are specified in the RGB (Red-Green-Blue) color space and are restricted to the 0.0 to 1.0 range. ``` However some software exports the geometry in their current base unit, e.g. millimeter. I'd suggest to add a `scale` parameter in the import file selector. There's two options for the implementation : 1. use this value to change the matrix of the object, i.e. set it's scale value for each axis 2. use this value to compute it's new size and position and leave the scale matrix to 1.0 I can produce a patch for any of these solutions. Which one is preferable ? The first solution is the least invasive.
Hombre57 self-assigned this 2024-08-09 16:38:57 +02:00
Hombre57 added the
enhancement
label 2024-08-09 16:39:16 +02:00
Cedric Steiert added the
task
label 2024-08-09 19:11:25 +02:00
Collaborator

I'm totally with you on this feature. A great improvement indeed, although probably only a very small user base might benefit from it.

However one tiny improvement suggestion from my side by having two new options instead of just one:

  • scale factor (like we have in e.g. the stl importer)
  • a drop down featuring source unit systems (which would set the scale factor accordingly). Tbh i was already thinking of adding that to the current stl exporter inside blender, as always resetting the scale factor for correct scaling is a true pain point (btw stl also does not save unit scale, it's usually assumed to be mm).

Which one is preferable ? The first solution is the least invasive.

As long as it works it doesn't matter tbh + users don't have to use it, which means that even if stuff sometimes breaks it's not too bad.
Probably the easiest solution would be just to do a simple mesh transform via API (as in adjusting the scale factor of the object). But keep in mind, that scaling of objects might result in different order of the objects in 3D space (if there are multiple objects), so the relations have to be kept intact.

I'm totally with you on this feature. A great improvement indeed, although probably only a very small user base might benefit from it. However one tiny improvement suggestion from my side by having two new options instead of just one: - scale factor (like we have in e.g. the stl importer) - a drop down featuring source unit systems (which would set the scale factor accordingly). Tbh i was already thinking of adding that to the current stl exporter inside blender, as always resetting the scale factor for correct scaling is a true pain point (btw stl also does not save unit scale, it's usually assumed to be mm). > Which one is preferable ? The first solution is the least invasive. As long as it works it doesn't matter tbh + users don't have to use it, which means that even if stuff sometimes breaks it's not too bad. Probably the easiest solution would be just to do a simple mesh transform via API (as in adjusting the scale factor of the object). But keep in mind, that scaling of objects might result in different order of the objects in 3D space (if there are multiple objects), so the relations have to be kept intact.
Collaborator

Btw for the how part you can also look up how other importers handle scaling, e.g. the legacy python stl exporter has it and it usually works well: https://projects.blender.org/extensions/io_mesh_stl

Btw for the how part you can also look up how other importers handle scaling, e.g. the legacy python stl exporter has it and it usually works well: https://projects.blender.org/extensions/io_mesh_stl
Author
Collaborator

I've created the import-scale branch that implement scaling, with a combobox for file unit selection or using a scale value. I chose to modify the base data instead of using the transformation matrix.

I still have to find out where to translate strings ...and find out how to add a branch directly to trunk in Eclipse 😊.

I've created the `import-scale` branch that implement scaling, with a combobox for file unit selection or using a scale value. I chose to modify the base data instead of using the transformation matrix. I still have to find out where to translate strings ...and find out how to add a branch directly to trunk in Eclipse 😊.
Collaborator

Hi, great so see you back. Unfortunately i'm currently a bit occupied by work, but i'd be glad to test and review once finished (just remove the WIP in the PR for that).

About string translations: https://docs.blender.org/api/current/bpy.app.translations.html
I assume you want the description text to be localized? If so, what languages? Currently there's only english, and most other addons also are just english i believe, however it for sure couldn't hurt to include some major languages as well.

Hi, great so see you back. Unfortunately i'm currently a bit occupied by work, but i'd be glad to test and review once finished (just remove the WIP in the PR for that). About string translations: https://docs.blender.org/api/current/bpy.app.translations.html I assume you want the description text to be localized? If so, what languages? Currently there's only english, and most other addons also are just english i believe, however it for sure couldn't hurt to include some major languages as well.
Author
Collaborator

Hi @Bujus_Krachus,

I'm still having trouble with my ISP regarding SSH connexion, and have some work to do in my flat too, but I'll try to do the things I've talked about or in mind as soon as possible.

Thanks for the link about translations. I was asking because some label (e.g. "scale") are automatically translated, and I was curious if translation could be easily done. I'll have a look.

I think the patch is finished but I want to test on more files first.

Hi @Bujus_Krachus, I'm still having trouble with my ISP regarding SSH connexion, and have some work to do in my flat too, but I'll try to do the things I've talked about or in mind as soon as possible. Thanks for the link about translations. I was asking because some label (e.g. "scale") are automatically translated, and I was curious if translation could be easily done. I'll have a look. I think the patch is finished but I want to test on more files first.
Collaborator

trouble [...] SSH connexion

tbh i actually prefer https over ssh. ssh may be more secure but also can be quite buggy from time to time (at least that's my experience with git over ssh).
When using the https link of a repo, simply clone it and authorize the user by logging in with the username and an application key (https://projects.blender.org/user/settings/applications).

I'll try to do the things I've talked about or in mind as soon as possible

As long as it's no hotfix, time is of no matter :D

some label (e.g. "scale") are automatically translated

i believe it's because blenders RNA System detects all translatable strings - and if they do have a translation from the official translation project they will be localized. This may include commonly used strings (or substrings) like scale, rotation, etc.

quoting from https://developer.blender.org/docs/handbook/translating/developer_guide/#python-translation-api:

Please note that here too, most messages are detected automatically. In particular, text parameter of all bpy.types.UILayout’s functions is handled as expected

> trouble [...] SSH connexion tbh i actually prefer https over ssh. ssh may be more secure but also can be quite buggy from time to time (at least that's my experience with git over ssh). When using the https link of a repo, simply clone it and authorize the user by logging in with the username and an application key (https://projects.blender.org/user/settings/applications). > I'll try to do the things I've talked about or in mind as soon as possible As long as it's no hotfix, time is of no matter :D > some label (e.g. "scale") are automatically translated i believe it's because blenders RNA System detects all translatable strings - and if they do have a translation from the official translation project they will be localized. This may include commonly used strings (or substrings) like scale, rotation, etc. quoting from https://developer.blender.org/docs/handbook/translating/developer_guide/#python-translation-api: > Please note that here too, most messages are detected automatically. In particular, text parameter of all bpy.types.UILayout’s functions is handled as expected
Collaborator

Merged to master, will close this task.

Merged to master, will close this task.
Sign in to join this conversation.
No description provided.