[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2681] contrib/py/scripts/addons/ io_import_pdb_atomic_blender.py:

Clemens Barth barth at root-1.de
Tue Nov 29 17:24:18 CET 2011


Revision: 2681
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2681
Author:   blendphys
Date:     2011-11-29 16:24:08 +0000 (Tue, 29 Nov 2011)
Log Message:
-----------


Dear all.

This is only a small change!
I was working with Atomic Blender (AB) today preparing some images for a discussion.
During separating single atoms from a structure in the 'Edit mode', AB 
switches back into the 'Object mode'. I think it is better if AB remains in 
the 'Edit mode' since one wishes to separate several single atoms one after
the other one - I changed the code a tiny bit. 
Certainly, I have done this after ideasman's corrections from
today (thanks ideasman).

Cheers,

Blendphys.

Modified Paths:
--------------
    contrib/py/scripts/addons/io_import_pdb_atomic_blender.py

Modified: contrib/py/scripts/addons/io_import_pdb_atomic_blender.py
===================================================================
--- contrib/py/scripts/addons/io_import_pdb_atomic_blender.py	2011-11-29 14:50:45 UTC (rev 2680)
+++ contrib/py/scripts/addons/io_import_pdb_atomic_blender.py	2011-11-29 16:24:08 UTC (rev 2681)
@@ -39,7 +39,7 @@
 #
 #  Start of project              : 2011-08-31 by Clemens Barth
 #  First publication in Blender  : 2011-11-11
-#  Last modified                 : 2011-11-28
+#  Last modified                 : 2011-11-29
 #
 #  Acknowledgements: Thanks to ideasman, meta_androcto, truman, kilon, 
 #  dairin0d, PKHG, Valter, etc 
@@ -411,10 +411,11 @@
         
         # Get first all important properties from the atom which the user
         # has chosen: location, color, scale
-        name = bpy.context.edit_object.name 
-        loc_obj_vec = bpy.context.edit_object.location 
-        scale = bpy.context.edit_object.children[0].scale
-        material = bpy.context.edit_object.children[0].active_material        
+        obj = bpy.context.edit_object
+        name = obj.name 
+        loc_obj_vec = obj.location 
+        scale = obj.children[0].scale
+        material = obj.children[0].active_material        
         
         # Separate the vertex from the main mesh and create a new mesh.
         bpy.ops.mesh.separate()
@@ -462,6 +463,14 @@
         new_atom.active_material = material
         new_atom.name = name + "_sep"
         
+        # Switch back into the 'Edit mode' because we would like to seprate
+        # other atoms may be (more convinient)
+        new_atom.select = False
+        obj.select = True
+        bpy.context.scene.objects.active = obj
+        bpy.ops.object.select_all(action='DESELECT')  
+        bpy.ops.object.mode_set(mode='EDIT', toggle=False)  
+ 
         return {'FINISHED'}
 
 
@@ -995,7 +1004,7 @@
         elif "ATOM" in line or "HETATM" in line:
 
             # What follows is due to deviations which appear from PDB to
-            # PDB file. it is very special. PLEASE, DO NOT CHANGE! From here ...
+            # PDB file. It is very special. PLEASE, DO NOT CHANGE! From here ...
             short_name = line[13:14]
             if short_name.isupper() == True:
                 if line[14:15].islower() == True:
@@ -1085,7 +1094,7 @@
 
 
 
-    # Here, the list of materials is built. 
+    # The list of materials is built. 
     # Note that all atoms of one type (e.g. all hydrogens) get only ONE 
     # material! This is good because then, by activating one atom in the 
     # Blender scene and changing the color of this atom, one changes the color 



More information about the Bf-extensions-cvs mailing list