Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-03 18:47:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-03-03 18:47:10 +0300
commit0753bd344d48c039a6cb26df2de54cf4e6ba5243 (patch)
treea5c5bb6bad134a30be156d60d4354e7e5f523a12 /io_scene_obj
parent96247bdb6cb4c9b39f04d57cb8d050782b538ac4 (diff)
this wasn't restored from 2.4x, fix [#26266] .OBJ import 'Clamp Scale' not working
also enable preset menu
Diffstat (limited to 'io_scene_obj')
-rw-r--r--io_scene_obj/__init__.py1
-rw-r--r--io_scene_obj/import_obj.py36
2 files changed, 20 insertions, 17 deletions
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 3c9c5b5c..2cee2efb 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -48,6 +48,7 @@ class ImportOBJ(bpy.types.Operator, ImportHelper):
'''Load a Wavefront OBJ File'''
bl_idname = "import_scene.obj"
bl_label = "Import OBJ"
+ bl_options = {'PRESET'}
filename_ext = ".obj"
filter_glob = StringProperty(default="*.obj;*.mtl", options={'HIDDEN'})
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index 1056fde0..12465453 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -1270,23 +1270,25 @@ def load(operator, context, filepath,
axis_min = [1000000000] * 3
axis_max = [-1000000000] * 3
-# if CLAMP_SIZE:
-# # Get all object bounds
-# for ob in new_objects:
-# for v in ob.getBoundBox():
-# for axis, value in enumerate(v):
-# if axis_min[axis] > value: axis_min[axis]= value
-# if axis_max[axis] < value: axis_max[axis]= value
-
-# # Scale objects
-# max_axis= max(axis_max[0]-axis_min[0], axis_max[1]-axis_min[1], axis_max[2]-axis_min[2])
-# scale= 1.0
-
-# while CLAMP_SIZE < max_axis * scale:
-# scale= scale/10.0
-
-# for ob in new_objects:
-# ob.setSize(scale, scale, scale)
+ if CLAMP_SIZE:
+ # Get all object bounds
+ for ob in new_objects:
+ for v in ob.bound_box:
+ for axis, value in enumerate(v):
+ if axis_min[axis] > value:
+ axis_min[axis] = value
+ if axis_max[axis] < value:
+ axis_max[axis] = value
+
+ # Scale objects
+ max_axis = max(axis_max[0] - axis_min[0], axis_max[1] - axis_min[1], axis_max[2] - axis_min[2])
+ scale = 1.0
+
+ while CLAMP_SIZE < max_axis * scale:
+ scale = scale / 10.0
+
+ for obj in new_objects:
+ obj.scale = scale, scale, scale
# Better rotate the vert locations
#if not ROTATE_X90: