[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1675] trunk/py/scripts/addons/ io_scene_obj: this wasn't restored from 2.4x, fix [#26266] .OBJ import ' Clamp Scale' not working

Campbell Barton ideasman42 at gmail.com
Thu Mar 3 16:47:11 CET 2011


Revision: 1675
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1675
Author:   campbellbarton
Date:     2011-03-03 15:47:10 +0000 (Thu, 03 Mar 2011)
Log Message:
-----------
this wasn't restored from 2.4x, fix [#26266] .OBJ import 'Clamp Scale' not working
also enable preset menu

Modified Paths:
--------------
    trunk/py/scripts/addons/io_scene_obj/__init__.py
    trunk/py/scripts/addons/io_scene_obj/import_obj.py

Modified: trunk/py/scripts/addons/io_scene_obj/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_scene_obj/__init__.py	2011-03-02 23:02:25 UTC (rev 1674)
+++ trunk/py/scripts/addons/io_scene_obj/__init__.py	2011-03-03 15:47:10 UTC (rev 1675)
@@ -48,6 +48,7 @@
     '''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'})

Modified: trunk/py/scripts/addons/io_scene_obj/import_obj.py
===================================================================
--- trunk/py/scripts/addons/io_scene_obj/import_obj.py	2011-03-02 23:02:25 UTC (rev 1674)
+++ trunk/py/scripts/addons/io_scene_obj/import_obj.py	2011-03-03 15:47:10 UTC (rev 1675)
@@ -1270,23 +1270,25 @@
     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
+    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
+        # 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
+        while CLAMP_SIZE < max_axis * scale:
+            scale = scale / 10.0
 
-#         for ob in new_objects:
-#             ob.setSize(scale, scale, scale)
+        for obj in new_objects:
+            obj.scale = scale, scale, scale
 
     # Better rotate the vert locations
     #if not ROTATE_X90:



More information about the Bf-extensions-cvs mailing list