Add feature #12: Scale geometry options for shape import #16
No reviewers
Labels
No Label
bug
confirmed
duplicate
enhancement
help wanted
High
known issue
Low
Normal
not a task
question
task
v2.4
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: extensions/io_scene_x3d#16
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Hombre57/io_scene_x3d:import-scale"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The geometry data is recomputed (positions, size, transformations),
without modifying the transformation matrix.
I'm quite satisifed with what you've already got here. 👍
Would be great if you could go through the comments and resolve or discuss them.
One thing i stumbled across: scaling does not work when using a primitive like box. I don't hink this was working before either but would be great if it would, especially now with the unit selector. I attached a simple test file, changing the unit does not result in the box being smaller. Is it possible to incllude such objects as well or is the implementation effort too high? If it's not possible please document it soemwhere, that scaling is only available with custom objects (indexed face set).
@ -39,1 +39,4 @@
file_unit: EnumProperty(
name="File Unit",
items=(('M', "Meter", "The VRML/x3D specification states that data have to be exported in Meter."),
three improvement suggestions:
@ -40,0 +40,4 @@
file_unit: EnumProperty(
name="File Unit",
items=(('M', "Meter", "The VRML/x3D specification states that data have to be exported in Meter."),
('DM', "Decimeter", ""),
Here are the descriptions missing. Two points that could be included:
I don't know if any software will use that scale, I don't think anyone will, but I added in the list all units between meter and millimeter. I hesitated to add the intermediate units... If you want a specific list of entries, just drop them in a comment below.
I'll add the scale in the comments for each entries.
@ -40,0 +41,4 @@
name="File Unit",
items=(('M', "Meter", "The VRML/x3D specification states that data have to be exported in Meter."),
('DM', "Decimeter", ""),
('CM', "Centimeter", ""),
description, see above
@ -40,0 +42,4 @@
items=(('M', "Meter", "The VRML/x3D specification states that data have to be exported in Meter."),
('DM', "Decimeter", ""),
('CM', "Centimeter", ""),
('MM', "Milimeter", ""),
description, see above
@ -40,0 +43,4 @@
('DM', "Decimeter", ""),
('CM', "Centimeter", ""),
('MM', "Milimeter", ""),
('IN', "Inch", ""),
description, see above
@ -40,0 +44,4 @@
('CM', "Centimeter", ""),
('MM', "Milimeter", ""),
('IN', "Inch", ""),
('CUSTOM', "Use scale", "Prefer scaling the geometry with the scale factor below"),
Done
@ -249,2 +269,4 @@
operator = sfile.active_operator
layout.prop(operator, "file_unit")
layout.prop(operator, "global_scale")
I would prefer the scale input to be disabled until entry CUSTOM is selected (to avoid confusion for users in a rush), this could maybe be achieved by this solution: https://blender.stackexchange.com/a/268840
Also on another note a small research question: is it possible to dynamically change the value of the scale field depending on the selected dropdown entry? Idk if this would be helpful for some to understand what each scale option means or if it just clutters the importer.
Widget sensitivity and update done. no need for scale in tooltips then.
@ -15,6 +15,7 @@ from itertools import chain
texture_cache = {}
material_cache = {}
conversionScale = 1.0
use snake_case
@ -682,3 +683,3 @@
return default
def getFieldAsFloat(self, field, default, ancestry):
def getFieldAsFloat(self, field, default, ancestry, s=1.0):
nitpick - be more descriptive: what does "s" mean? I sit speed, symmetry, similarity, simplicity, maybe even scale?
@ -701,3 +702,3 @@
return default
def getFieldAsFloatTuple(self, field, default, ancestry):
def getFieldAsFloatTuple(self, field, default, ancestry, s=1.0):
nitpick - be more descriptive: what does "s" mean? I sit speed, symmetry, similarity, simplicity, maybe even scale?
@ -3597,2 +3610,4 @@
# Used when adding blender primitives
GLOBALS['CIRCLE_DETAIL'] = PREF_CIRCLE_DIV
global conversionScale
use snake_case
@ -3599,0 +3612,4 @@
global conversionScale
units_factor = {'M': 1.0, 'DM': 0.1, 'CM': 0.01, 'MM': 0.001, 'IN': 0.0254}
uppercase for readability as it seems to be a constant.
Done
@ -40,0 +53,4 @@
global_scale: FloatProperty(
name="Scale",
min=0.001, max=1000.0,
default=1.0,
please also add
step=1.0,
. Currently it steps in intervals of 0.03, 0.01 seems more appropriate (or is 0.03 more comfy?). Could be also adjusted for the x3d exporter in line 220.Done
@Bujus_Krachus
It was already working for standard cases where the box size is provided in the file. The default values were not scaled, but they are now.
Nicely done 👍
Also big thanks that my little box now works as expected and for the dynamic default values in the scale input field :)
One small naming change (see comment) would be required, but then up until now ready to get added as new feature. If you think you're finished just remove the WIP.
@ -40,0 +56,4 @@
default=1.0,
precision=4,
step=1.0,
description="Scale value used when 'File Unit' is set to 'Use scale'",
'Use scale' now needs to be adjusted to the new name (CUSTOM)
WIP: Fix issue #12: Scale geometry when importing shapesto WIP: Add feature #12: Scale geometry options for shape importUnfortunately i just discovered that now x3d import is broken. The attached sample file got exported by blender and is the default cube. Import now throws this error:
UnboundLocalError: cannot access local variable 'apply_scale' where it is not associated with a value
That should get fixed
WIP: Add feature #12: Scale geometry options for shape importto Add feature #12: Scale geometry options for shape importThanks for the sample file @Bujus_Krachus . I hope everything is fixed now.
Seems good to me, thanks for the contribution :)
Translations as mentioned in #12 (comment) can be done later, still a bit undecided which languages to include, for further info see #17.
It would be great to have the unit type selctor also available for the x3d exporter, see #18. If you have some time left i'd be glad to see that added as well for the next release.
Will merge to master and publish the new version when either enough changes accumulated or at latest shortly after the upcoming blender 4.3 release in november.