[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3021] trunk/py/scripts/addons/ io_mesh_pdb/export_pdb.py:

Clemens Barth barth at root-1.de
Sun Feb 26 23:22:21 CET 2012


Revision: 3021
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3021
Author:   blendphys
Date:     2012-02-26 22:22:20 +0000 (Sun, 26 Feb 2012)
Log Message:
-----------

Dear all.

This is the first version of the EXPORTER for PDB files. 

- small changes in __init__.py
- new file: export_pdb.py

This week I'm going to test the exporter ... improvements will follow.

Blendphys 

Added Paths:
-----------
    trunk/py/scripts/addons/io_mesh_pdb/export_pdb.py

Added: trunk/py/scripts/addons/io_mesh_pdb/export_pdb.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_pdb/export_pdb.py	                        (rev 0)
+++ trunk/py/scripts/addons/io_mesh_pdb/export_pdb.py	2012-02-26 22:22:20 UTC (rev 3021)
@@ -0,0 +1,108 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+#
+#
+#  Authors           : Clemens Barth (Blendphys at root-1.de), ...
+#
+#  Homepage(Wiki)    : http://development.root-1.de/Atomic_Blender.php
+#  Tracker           : http://projects.blender.org/tracker/index.php?func=detail&aid=29226&group_id=153&atid=467
+#
+#  Start of project              : 2011-08-31 by Clemens Barth
+#  First publication in Blender  : 2011-11-11
+#  Last modified                 : 2012-02-07
+#
+#  Acknowledgements: Thanks to ideasman, meta_androcto, truman, kilon,
+#  dairin0d, PKHG, Valter, etc
+#
+
+import bpy
+import io
+import math
+import os
+import copy
+from math import pi, cos, sin
+from mathutils import Vector, Matrix
+from copy import copy
+
+from . import import_pdb
+
+ATOM_PDB_FILEPATH = ""
+ATOM_PDB_PDBTEXT  = (  "REMARK This pdb file has been created with Blender "
+                     + "and the Atomic Blender script\n"
+                     + "REMARK For more details see wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/PDB\n"
+                     + "REMARK\n"
+                     + "REMARK\n")
+
+
+
+
+class CLASS_atom_pdb_atoms_export(object):  
+    __slots__ = ('element', 'location')
+    def __init__(self, element, location):
+        self.element  = element
+        self.location = location
+
+
+
+
+def DEF_atom_pdb_export():
+
+    list_atoms = []
+    for obj in bpy.context.selected_objects:
+    
+        if "Stick" in obj.name:
+            continue
+            
+        if obj.type != "SURFACE" and obj.type != "MESH":
+            continue
+        
+        for element in import_pdb.ATOM_PDB_ELEMENTS:
+            if element.name in obj.name:
+                if element.short_name == "Vac":
+                    name = "X"
+                else:
+                    name = element.short_name
+
+                if len(obj.children) != 0:
+                    for vertex in obj.data.vertices:
+                        list_atoms.append(CLASS_atom_pdb_atoms_export(
+                                                       name,
+                                                       obj.location+vertex.co))
+                        
+                else:
+                    list_atoms.append(CLASS_atom_pdb_atoms_export(
+                                                       name,
+                                                       obj.location))
+                                                       
+                    
+    pdb_file_p = open(ATOM_PDB_FILEPATH, "w")
+    pdb_file_p.write(ATOM_PDB_PDBTEXT)
+
+    for i, atom in enumerate(list_atoms):
+        string = "ATOM %6d%3s%24.3f%8.3f%8.3f%6.2f%6.2f%12s\n" % (
+                                      i, atom.element,
+                                      atom.location[0],
+                                      atom.location[1],
+                                      atom.location[2],
+                                      1.00, 1.00, atom.element)
+        pdb_file_p.write(string)
+
+    pdb_file_p.close()
+
+    return True



More information about the Bf-extensions-cvs mailing list