diff options
author | Clemens Barth <barth@root-1.de> | 2012-11-10 01:53:49 +0400 |
---|---|---|
committer | Clemens Barth <barth@root-1.de> | 2012-11-10 01:53:49 +0400 |
commit | cdab4a56cb35f2bf5bd41942e82edcc3dc9bb744 (patch) | |
tree | b60a1a4f6ecdb2ccfeee9e260837d4386e491f8a /io_mesh_pdb/export_pdb.py | |
parent | bf9f42d9b5b08ce83439114c7872d254999c89a3 (diff) |
As in the case of the XYZ IE, names of classes and functions were changed,
according to the "Style Guide for Python Code"
(http://www.python.org/dev/peps/pep-0008/) and the recent review
(http://codereview.appspot.com/6815052). Some slight changes were done, too.
Extensive tests have shown that the code is still well working.
Blendphys
Diffstat (limited to 'io_mesh_pdb/export_pdb.py')
-rw-r--r-- | io_mesh_pdb/export_pdb.py | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/io_mesh_pdb/export_pdb.py b/io_mesh_pdb/export_pdb.py index cdd3e818..515f9482 100644 --- a/io_mesh_pdb/export_pdb.py +++ b/io_mesh_pdb/export_pdb.py @@ -17,32 +17,17 @@ # ##### END GPL LICENSE BLOCK ##### 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 addon Atomic Blender - PDB\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): +class AtomPropExport(object): __slots__ = ('element', 'location') def __init__(self, element, location): self.element = element self.location = location -def DEF_atom_pdb_export(obj_type): +def export_pdb(obj_type, filepath_pdb): list_atoms = [] for obj in bpy.context.selected_objects: @@ -54,7 +39,7 @@ def DEF_atom_pdb_export(obj_type): continue name = "" - for element in import_pdb.ATOM_PDB_ELEMENTS_DEFAULT: + for element in import_pdb.ELEMENTS_DEFAULT: if element[1] in obj.name: if element[2] == "Vac": name = "X" @@ -70,18 +55,19 @@ def DEF_atom_pdb_export(obj_type): if len(obj.children) != 0: for vertex in obj.data.vertices: location = obj.matrix_world*vertex.co - list_atoms.append(CLASS_atom_pdb_atoms_export( - name, - location)) + list_atoms.append(AtomPropExport(name, location)) else: if not obj.parent: location = obj.location - list_atoms.append(CLASS_atom_pdb_atoms_export( - name, - location)) + list_atoms.append(AtomPropExport(name, location)) - pdb_file_p = open(ATOM_PDB_FILEPATH, "w") - pdb_file_p.write(ATOM_PDB_PDBTEXT) + pdb_file_p = open(filepath_pdb, "w") + pdb_file_p.write("REMARK This pdb file has been created with Blender " + "and the addon Atomic Blender - PDB\n" + "REMARK For more details see wiki.blender.org/index.php/" + "Extensions:2.6/Py/Scripts/Import-Export/PDB\n" + "REMARK\n" + "REMARK\n") for i, atom in enumerate(list_atoms): string = "ATOM %6d%3s%24.3f%8.3f%8.3f%6.2f%6.2f%12s\n" % ( |