[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1866] trunk/py/scripts/addons/ io_scene_obj: rename obj import vars

Campbell Barton ideasman42 at gmail.com
Mon Apr 25 07:51:01 CEST 2011


Revision: 1866
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1866
Author:   campbellbarton
Date:     2011-04-25 05:51:01 +0000 (Mon, 25 Apr 2011)
Log Message:
-----------
rename obj import vars

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-04-25 05:11:32 UTC (rev 1865)
+++ trunk/py/scripts/addons/io_scene_obj/__init__.py	2011-04-25 05:51:01 UTC (rev 1866)
@@ -56,18 +56,18 @@
     filename_ext = ".obj"
     filter_glob = StringProperty(default="*.obj;*.mtl", options={'HIDDEN'})
 
-    CREATE_SMOOTH_GROUPS = BoolProperty(name="Smooth Groups", description="Surround smooth groups by sharp edges", default=True)
-    CREATE_FGONS = BoolProperty(name="NGons as FGons", description="Import faces with more then 4 verts as fgons", default=True)
-    CREATE_EDGES = BoolProperty(name="Lines as Edges", description="Import lines and faces with 2 verts as edge", default=True)
-    SPLIT_OBJECTS = BoolProperty(name="Object", description="Import OBJ Objects into Blender Objects", default=True)
-    SPLIT_GROUPS = BoolProperty(name="Group", description="Import OBJ Groups into Blender Objects", default=True)
+    use_smooth_groups = BoolProperty(name="Smooth Groups", description="Surround smooth groups by sharp edges", default=True)
+    use_ngons = BoolProperty(name="NGons as FGons", description="Import faces with more then 4 verts as fgons", default=True)
+    use_edges = BoolProperty(name="Lines as Edges", description="Import lines and faces with 2 verts as edge", default=True)
+    use_split_objects = BoolProperty(name="Object", description="Import OBJ Objects into Blender Objects", default=True)
+    use_split_groups = BoolProperty(name="Group", description="Import OBJ Groups into Blender Objects", default=True)
     # old comment: only used for user feedback
     # disabled this option because in old code a handler for it disabled SPLIT* params, it's not passed to load_obj
     # KEEP_VERT_ORDER = BoolProperty(name="Keep Vert Order", description="Keep vert and face order, disables split options, enable for morph targets", default= True)
-    ROTATE_X90 = BoolProperty(name="-X90", description="Rotate X 90.", default=True)
-    CLAMP_SIZE = FloatProperty(name="Clamp Scale", description="Clamp the size to this maximum (Zero to Disable)", min=0.0, max=1000.0, soft_min=0.0, soft_max=1000.0, default=0.0)
-    POLYGROUPS = BoolProperty(name="Poly Groups", description="Import OBJ groups as vertex groups.", default=False)
-    IMAGE_SEARCH = BoolProperty(name="Image Search", description="Search subdirs for any assosiated images (Warning, may be slow)", default=True)
+    use_rotate_x90 = BoolProperty(name="-X90", description="Rotate X 90.", default=True)
+    global_clamp_size = FloatProperty(name="Clamp Scale", description="Clamp the size to this maximum (Zero to Disable)", min=0.0, max=1000.0, soft_min=0.0, soft_max=1000.0, default=0.0)
+    use_groups_as_vgroups = BoolProperty(name="Poly Groups", description="Import OBJ groups as vertex groups.", default=False)
+    use_image_search = BoolProperty(name="Image Search", description="Search subdirs for any assosiated images (Warning, may be slow)", default=True)
 
     def execute(self, context):
         # print("Selected: " + context.active_object.name)

Modified: trunk/py/scripts/addons/io_scene_obj/import_obj.py
===================================================================
--- trunk/py/scripts/addons/io_scene_obj/import_obj.py	2011-04-25 05:11:32 UTC (rev 1865)
+++ trunk/py/scripts/addons/io_scene_obj/import_obj.py	2011-04-25 05:51:01 UTC (rev 1866)
@@ -239,7 +239,7 @@
         return b' '.join(line_split[1:])
 
 
-def obj_image_load(imagepath, DIR, IMAGE_SEARCH):
+def obj_image_load(imagepath, DIR, use_image_search):
     if b'_' in imagepath:
         image = load_image(imagepath.replace(b'_', b' '), DIR)
         if image:
@@ -252,25 +252,25 @@
     print("failed to load %r doesn't exist" % imagepath)
     return None
 
-# def obj_image_load(imagepath, DIR, IMAGE_SEARCH):
+# def obj_image_load(imagepath, DIR, use_image_search):
 #     '''
 #     Mainly uses comprehensiveImageLoad
 #     but tries to replace '_' with ' ' for Max's exporter replaces spaces with underscores.
 #     '''
 
 #     if '_' in imagepath:
-#         image= BPyImage.comprehensiveImageLoad(imagepath, DIR, PLACE_HOLDER= False, RECURSIVE= IMAGE_SEARCH)
+#         image= BPyImage.comprehensiveImageLoad(imagepath, DIR, PLACE_HOLDER= False, RECURSIVE= use_image_search)
 #         if image: return image
 #         # Did the exporter rename the image?
-#         image= BPyImage.comprehensiveImageLoad(imagepath.replace('_', ' '), DIR, PLACE_HOLDER= False, RECURSIVE= IMAGE_SEARCH)
+#         image= BPyImage.comprehensiveImageLoad(imagepath.replace('_', ' '), DIR, PLACE_HOLDER= False, RECURSIVE= use_image_search)
 #         if image: return image
 
 #     # Return an image, placeholder if it dosnt exist
-#     image= BPyImage.comprehensiveImageLoad(imagepath, DIR, PLACE_HOLDER= True, RECURSIVE= IMAGE_SEARCH)
+#     image= BPyImage.comprehensiveImageLoad(imagepath, DIR, PLACE_HOLDER= True, RECURSIVE= use_image_search)
 #     return image
 
 
-def create_materials(filepath, material_libs, unique_materials, unique_material_images, IMAGE_SEARCH):
+def create_materials(filepath, material_libs, unique_materials, unique_material_images, use_image_search):
     '''
     Create all the used materials in this obj,
     assign colors and images to the materials from all referenced material libs
@@ -285,7 +285,7 @@
         texture = bpy.data.textures.new(name=type, type='IMAGE')
 
         # Absolute path - c:\.. etc would work here
-        image = obj_image_load(imagepath, DIR, IMAGE_SEARCH)
+        image = obj_image_load(imagepath, DIR, use_image_search)
         has_data = False
 
         if image:
@@ -604,13 +604,13 @@
     return [(value[0], value[1], value[2], key_to_name(key)) for key, value in list(face_split_dict.items())]
 
 
-def create_mesh(new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, verts_tex, faces, unique_materials, unique_material_images, unique_smooth_groups, vertex_groups, dataname):
+def create_mesh(new_objects, has_ngons, use_ngons, use_edges, verts_loc, verts_tex, faces, unique_materials, unique_material_images, unique_smooth_groups, vertex_groups, dataname):
     '''
     Takes all the data gathered and generates a mesh, adding the new object to new_objects
     deals with fgons, sharp edges and assigning materials
     '''
     if not has_ngons:
-        CREATE_FGONS = False
+        use_ngons = False
 
     if unique_smooth_groups:
         sharp_edges = {}
@@ -619,7 +619,7 @@
 
     # Split fgons into tri's
     fgon_edges = {}  # Used for storing fgon keys
-    if CREATE_EDGES:
+    if use_edges:
         edges = []
 
     context_object = None
@@ -639,7 +639,7 @@
             faces.pop(f_idx)  # cant add single vert faces
 
         elif not face_vert_tex_indices or len_face_vert_loc_indices == 2:  # faces that have no texture coords are lines
-            if CREATE_EDGES:
+            if use_edges:
                 # generators are better in python 2.4+ but can't be used in 2.3
                 # edges.extend( (face_vert_loc_indices[i], face_vert_loc_indices[i+1]) for i in xrange(len_face_vert_loc_indices-1) )
                 edges.extend([(face_vert_loc_indices[i], face_vert_loc_indices[i + 1]) for i in range(len_face_vert_loc_indices - 1)])
@@ -680,7 +680,7 @@
                 )
 
                 # edges to make fgons
-                if CREATE_FGONS:
+                if use_ngons:
                     edge_users = {}
                     for ngon in ngon_face_indices:
                         for i in (0, 1, 2):
@@ -744,7 +744,7 @@
         if len(face[0]) < 2:
             pass  # raise "bad face"
         elif len(face[0]) == 2:
-            if CREATE_EDGES:
+            if use_edges:
                 edges.append(face[0])
         else:
 
@@ -801,10 +801,10 @@
     del me_faces
 #     del ALPHA
 
-    if CREATE_EDGES and not edges:
-        CREATE_EDGES = False
+    if use_edges and not edges:
+        use_edges = False
 
-    if CREATE_EDGES:
+    if use_edges:
         me.edges.add(len(edges))
 
         # edges should be a list of (a, b) tuples
@@ -820,13 +820,13 @@
         return (e1[0] == e2[0] and e1[1] == e2[1]) or (e1[0] == e2[1] and e1[1] == e2[0])
 
     # XXX slow
-#     if CREATE_FGONS and fgon_edges:
+#     if use_ngons and fgon_edges:
 #         for fgon_edge in fgon_edges.keys():
 #             for ed in me.edges:
 #                 if edges_match(fgon_edge, ed.vertices):
 #                     ed.is_fgon = True
 
-#     if CREATE_FGONS and fgon_edges:
+#     if use_ngons and fgon_edges:
 #         FGON= Mesh.EdgeFlags.FGON
 #         for ed in me.findEdges( fgon_edges.keys() ):
 #             if ed is not None:
@@ -848,7 +848,7 @@
 #         del SHARP
 
     me.validate()
-    me.update(calc_edges=CREATE_EDGES)
+    me.update(calc_edges=use_edges)
 
     ob = bpy.data.objects.new("Mesh", me)
     new_objects.append(ob)
@@ -963,15 +963,15 @@
 
 
 def load(operator, context, filepath,
-         CLAMP_SIZE=0.0,
-         CREATE_FGONS=True,
-         CREATE_SMOOTH_GROUPS=True,
-         CREATE_EDGES=True,
-         SPLIT_OBJECTS=True,
-         SPLIT_GROUPS=True,
-         ROTATE_X90=True,
-         IMAGE_SEARCH=True,
-         POLYGROUPS=False):
+         global_clamp_size=0.0,
+         use_ngons=True,
+         use_smooth_groups=True,
+         use_edges=True,
+         use_split_objects=True,
+         use_split_groups=True,
+         use_rotate_x90=True,
+         use_image_search=True,
+         use_groups_as_vgroups=False):
     '''
     Called by the user interface or another script.
     load_obj(path) - should give acceptable results.
@@ -982,8 +982,8 @@
 
     filepath = filepath.encode()
 
-    if SPLIT_OBJECTS or SPLIT_GROUPS:
-        POLYGROUPS = False
+    if use_split_objects or use_split_groups:
+        use_groups_as_vgroups = False
 
     time_main = time.time()
 
@@ -991,7 +991,7 @@
     verts_tex = []
     faces = []  # tuples of the faces
     material_libs = []  # filanems to material libs this uses
-    vertex_groups = {}  # when POLYGROUPS is true
+    vertex_groups = {}  # when use_groups_as_vgroups is true
 
     # Get the string to float conversion func for this file- is 'float' for almost all files.
     float_func = get_float_func(filepath)
@@ -1074,7 +1074,7 @@
                 vert_loc_index = int(obj_vert[0]) - 1

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list