[Bf-extensions-cvs] [591e04b] dxf_import: Fixes in own callbacks stuff.

Bastien Montagne noreply at git.blender.org
Fri Aug 15 12:38:32 CEST 2014


Commit: 591e04bfd25164b1feddf7cbf85d9bf8ddc63419
Author: Bastien Montagne
Date:   Fri Aug 15 12:30:44 2014 +0200
Branches: dxf_import
https://developer.blender.org/rBA591e04bfd25164b1feddf7cbf85d9bf8ddc63419

Fixes in own callbacks stuff.

===================================================================

M	io_import_dxf/__init__.py

===================================================================

diff --git a/io_import_dxf/__init__.py b/io_import_dxf/__init__.py
index a4a46d2..25adb7c 100644
--- a/io_import_dxf/__init__.py
+++ b/io_import_dxf/__init__.py
@@ -132,6 +132,38 @@ def display_groups_in_outliner():
         outliner.spaces[0].display_mode = "GROUPS"
 
 
+# Update helpers (must be globals to be re-usable).
+def _update_use_scene_srid_do(self, context):
+    if not self.create_new_scene:
+        scene = context.scene
+        # Try to get Scene SRID (ESPG) data from current scene.
+        srid = scene.get("SRID", None)
+        if srid is not None:
+            self.internal_using_scene_srid = True
+            if srid == 'TMERC':
+                self.proj_scene = 'TMERC'
+                self.merc_scene_lat = scene.get('latitude', 0)
+                self.merc_scene_lon = scene.get('longitude', 0)
+            else:
+                self.proj_scene = 'USER'
+                self.epsg_scene_user = srid
+        else:
+            self.internal_using_scene_srid = False
+
+
+def _update_recenter_do(self, context):
+    scene = context.scene
+    if self.dxf_indi == 'SPHERICAL' or self.proj_scene == 'TMERC' or \
+       (not self.create_new_scene and is_ref_scene(scene)):
+        self.recenter = False
+
+
+def _update_proj_scene_do(self, context):
+    # make sure scene EPSG is not None if DXF EPSG is not None
+    if self.proj_scene == 'NONE' and self.proj_dxf != 'NONE':
+        self.proj_scene = self.proj_dxf
+
+
 class IMPORT_OT_dxf(bpy.types.Operator):
     """Import from DXF file format (.dxf)"""
     bl_idname = "import_scene.dxf"
@@ -212,21 +244,7 @@ class IMPORT_OT_dxf(bpy.types.Operator):
             )
 
     def _update_use_scene_srid(self, context):
-        if not self.create_new_scene:
-            scene = context.scene
-            # Try to get Scene SRID (ESPG) data from current scene.
-            srid = scene.get("SRID", None)
-            if srid is not None:
-                self.internal_using_scene_srid = True
-                if srid == 'TMERC':
-                    self.proj_scene = 'TMERC'
-                    self.merc_scene_lat = scene.get('latitude', 0)
-                    self.merc_scene_lon = scene.get('longitude', 0)
-                else:
-                    self.proj_scene = 'USER'
-                    self.epsg_scene_user = srid
-            else:
-                self.internal_using_scene_srid = False
+        _update_use_scene_srid_do(self, context)
     use_scene_srid = BoolProperty(
             name="Use SRID From Scene",
             description="Try to use SRID property value from current Scene, if available",
@@ -235,8 +253,8 @@ class IMPORT_OT_dxf(bpy.types.Operator):
             )
 
     def _update_create_new_scene(self, context):
-        self._update_use_scene_srid(self, context)
-        self._update_recenter(self, context)
+        _update_use_scene_srid_do(self, context)
+        _update_recenter_do(self, context)
     create_new_scene = BoolProperty(
             name="Import DXF to new scene",
             description="Creates a new scene with the name of the imported file",
@@ -245,14 +263,12 @@ class IMPORT_OT_dxf(bpy.types.Operator):
             )
 
     def _update_recenter(self, context):
-        scene = context.scene
-        if self.dxf_indi == 'SPHERICAL' or self.proj_scene == 'TMERC' or \
-           (not self.create_new_scene and is_ref_scene(scene)):
-            self.recenter = False
+        _update_recenter_do(self, context)
     recenter = BoolProperty(
             name="Center Geometry",
             description="Moves geometry to the center of the scene",
-            default=T_Recenter
+            default=T_Recenter,
+            update=_update_recenter,
             )
 
     thickness_and_width = BoolProperty(
@@ -285,11 +301,9 @@ class IMPORT_OT_dxf(bpy.types.Operator):
             default="1.0"
             )
 
-    def _update_proj_scene(self, context):
-        # make sure scene EPSG is not None if DXF EPSG is not None
-        if self.proj_scene == 'NONE' and self.proj_dxf != 'NONE':
-            self.proj_scene = self.proj_dxf
-        self._update_recenter(self, context)
+    def _update_proj(self, context):
+        _update_proj_scene_do(self, context)
+        _update_recenter_do(self, context)
     # XXX proj_epsg_items even if not PYPROJ?
     pitems = proj_none_items + proj_user_items + proj_epsg_items
     proj_dxf = EnumProperty(
@@ -297,7 +311,7 @@ class IMPORT_OT_dxf(bpy.types.Operator):
             description="The coordinate system for the DXF file (check http://epsg.io)",
             items=pitems,
             default='NONE',
-            update=_update_proj_scene,
+            update=_update_proj,
             )
 
     epsg_dxf_user = StringProperty(name="EPSG-Code", default="EPSG")
@@ -310,7 +324,7 @@ class IMPORT_OT_dxf(bpy.types.Operator):
             description="The coordinate system for the Scene (check http://epsg.io)",
             items=pitems,
             default='NONE',
-            update=_update_proj_scene,
+            update=_update_proj,
             )
 
     epsg_scene_user = StringProperty(name="EPSG-Code", default="EPSG")



More information about the Bf-extensions-cvs mailing list