[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3945] contrib/py/scripts/addons/ io_atomblend_utilities: Some cosmetics of the code.

Clemens Barth barth at root-1.de
Fri Nov 9 21:07:56 CET 2012


Revision: 3945
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3945
Author:   blendphys
Date:     2012-11-09 20:07:49 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
Some cosmetics of the code.

Blendphys

Modified Paths:
--------------
    contrib/py/scripts/addons/io_atomblend_utilities/__init__.py
    contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py

Modified: contrib/py/scripts/addons/io_atomblend_utilities/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_atomblend_utilities/__init__.py	2012-11-09 19:54:56 UTC (rev 3944)
+++ contrib/py/scripts/addons/io_atomblend_utilities/__init__.py	2012-11-09 20:07:49 UTC (rev 3945)
@@ -49,8 +49,6 @@
     "category": "Import-Export"
 }
 
-import os
-import io
 import bpy
 from bpy.types import Operator, Panel
 from bpy.props import (StringProperty,
@@ -61,7 +59,6 @@
 
 from . import io_atomblend_utilities
 
-
 # -----------------------------------------------------------------------------
 #                                                                           GUI
 
@@ -120,7 +117,6 @@
         row.operator( "atom_blend.separate_atom" )
 
 
-
 class PanelProperties(bpy.types.PropertyGroup):
 
     def Callback_radius_type(self, context):
@@ -130,7 +126,6 @@
                                               None,
                                               None,
                                               scn.radius_type) 
-
     def Callback_radius_pm(self, context):
         scn = bpy.context.scene.atom_blend[0]
         io_atomblend_utilities.choose_objects("radius_pm", 
@@ -258,8 +253,6 @@
         return {'FINISHED'}
 
 
-
-
 def register():
     io_atomblend_utilities.read_elements()  
     bpy.utils.register_module(__name__)
@@ -267,8 +260,6 @@
                                                    PanelProperties)
     bpy.context.scene.atom_blend.add()
 
-
-    
 def unregister():
     bpy.utils.unregister_module(__name__)
 

Modified: contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py
===================================================================
--- contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py	2012-11-09 19:54:56 UTC (rev 3944)
+++ contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py	2012-11-09 20:07:49 UTC (rev 3945)
@@ -16,14 +16,10 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-import io
 import os
 import bpy
 import bmesh
 
-from math import pi, cos, sin
-from mathutils import Vector, Matrix
-
 # This variable contains the path of the XYZ file.
 # It is used almost everywhere, which explains why it
 # should stay global. First, it is empty and gets 'filled' directly
@@ -45,7 +41,7 @@
 # charge states for any atom are listed, if existing.
 # The list is fixed and cannot be changed ... (see below)
 
-ATOM_BLEND_ELEMENTS_DEFAULT = (
+ELEMENTS_DEFAULT = (
 ( 1,      "Hydrogen",        "H", (  1.0,   1.0,   1.0), 0.32, 0.32, 0.79 , -1 , 1.54 ),
 ( 2,        "Helium",       "He", ( 0.85,   1.0,   1.0), 0.93, 0.93, 0.49 ),
 ( 3,       "Lithium",       "Li", (  0.8,  0.50,   1.0), 1.23, 1.23, 2.05 ,  1 , 0.68 ),
@@ -161,7 +157,7 @@
 # have then one fixed list (above), which will never be changed, and a list of
 # classes with same data. The latter can be modified via loading a separate
 # custom data file for instance.
-ATOM_BLEND_ELEMENTS = []
+ELEMENTS = []
 
 # This is the class, which stores the properties for one element.
 class ElementProp(object):
@@ -178,7 +174,6 @@
 # -----------------------------------------------------------------------------
 #                                                          Some small routines
 
-
 # This function measures the distance between two objects (atoms),
 # which are active.
 def distance():
@@ -231,7 +226,6 @@
                                    radius_all, 
                                    radius_pm, 
                                    radius_type)
-
     if who == "ALL_ACTIVE":
         for obj in bpy.context.selected_objects:
             if len(obj.children) != 0:
@@ -265,7 +259,7 @@
               
     # Radius type 
     if how == "radius_type":
-        for element in ATOM_BLEND_ELEMENTS:
+        for element in ELEMENTS:
             if element.name in obj.name:
                 obj.scale = (element.radii[int(radius_type)],) * 3
 
@@ -273,9 +267,9 @@
 # Read the default element list.
 def read_elements():
 
-    ATOM_BLEND_ELEMENTS[:] = []
+    ELEMENTS[:] = []
 
-    for item in ATOM_BLEND_ELEMENTS_DEFAULT:
+    for item in ELEMENTS_DEFAULT:
 
         # All three radii into a list
         radii = [item[4],item[5],item[6]]
@@ -285,7 +279,7 @@
 
         li = ElementProp(item[0],item[1],item[2],item[3],
                                      radii,radii_ionic)
-        ATOM_BLEND_ELEMENTS.append(li)
+        ELEMENTS.append(li)
 
 
 # Change color and radii by uisnf the list of elements.
@@ -295,13 +289,13 @@
         if len(obj.children) != 0:
             child = obj.children[0]
             if child.type in {'SURFACE', 'MESH'}:
-                for element in ATOM_BLEND_ELEMENTS:
+                for element in ELEMENTS:
                     if element.name in obj.name:
                         child.scale = (element.radii[0],) * 3
                         child.active_material.diffuse_color = element.color
         else:
             if obj.type in {'SURFACE', 'MESH'}:
-                for element in ATOM_BLEND_ELEMENTS:
+                for element in ELEMENTS:
                     if element.name in obj.name:
                         obj.scale = (element.radii[0],) * 3
                         obj.active_material.diffuse_color = element.color
@@ -319,11 +313,11 @@
         return False
 
     # The whole list gets deleted! We build it new.
-    ATOM_BLEND_ELEMENTS[:] = []
+    ELEMENTS[:] = []
 
     # Read the data file, which contains all data
     # (atom name, radii, colors, etc.)
-    data_file_p = io.open(path_datafile, "r")
+    data_file_p = open(path_datafile, "r")
 
     for line in data_file_p:
 
@@ -360,14 +354,13 @@
             element = ElementProp(number,name,short_name,color,
                                               radii, radii_ionic)
 
-            ATOM_BLEND_ELEMENTS.append(element)
+            ELEMENTS.append(element)
 
     data_file_p.close()
 
     return True
 
 
-
 # Routine for separating atoms from a dupliverts strucutre.
 def separate_atoms(scn):
 



More information about the Bf-extensions-cvs mailing list