1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
20 from io_mesh_atomic
.pdb_import
import ELEMENTS_DEFAULT
22 class AtomPropExport(object):
23 __slots__
= ('element', 'location')
24 def __init__(self
, element
, location
):
25 self
.element
= element
26 self
.location
= location
29 def export_pdb(obj_type
, filepath_pdb
):
32 for obj
in bpy
.context
.selected_objects
:
34 if "STICK" in obj
.name
.upper():
37 if obj
.type not in {'MESH', 'SURFACE', 'META'}:
41 for element
in ELEMENTS_DEFAULT
:
42 if element
[1] in obj
.name
:
43 if element
[2] == "Vac":
54 if len(obj
.children
) != 0:
55 for vertex
in obj
.data
.vertices
:
56 location
= obj
.matrix_world
@ vertex
.co
57 list_atoms
.append(AtomPropExport(name
, location
))
60 location
= obj
.location
61 list_atoms
.append(AtomPropExport(name
, location
))
63 pdb_file_p
= open(filepath_pdb
, "w")
64 pdb_file_p
.write("REMARK This pdb file has been created with Blender "
65 "and the addon Atomic Blender - PDB\n"
66 "REMARK For more details see the wiki pages of Blender.\n"
70 for i
, atom
in enumerate(list_atoms
):
71 string
= "ATOM %6d%3s%24.3f%8.3f%8.3f%6.2f%6.2f%12s\n" % (
76 1.00, 1.00, atom
.element
)
77 pdb_file_p
.write(string
)