1 # SPDX-License-Identifier: GPL-2.0-or-later
4 from io_mesh_atomic
.pdb_import
import ELEMENTS_DEFAULT
6 class AtomPropExport(object):
7 __slots__
= ('element', 'location')
8 def __init__(self
, element
, location
):
10 self
.location
= location
13 def export_pdb(obj_type
, filepath_pdb
):
16 for obj
in bpy
.context
.selected_objects
:
18 if "STICK" in obj
.name
.upper():
21 if obj
.type not in {'MESH', 'SURFACE', 'META'}:
25 for element
in ELEMENTS_DEFAULT
:
26 if element
[1] in obj
.name
:
27 if element
[2] == "Vac":
38 if len(obj
.children
) != 0:
39 for vertex
in obj
.data
.vertices
:
40 location
= obj
.matrix_world
@ vertex
.co
41 list_atoms
.append(AtomPropExport(name
, location
))
44 location
= obj
.location
45 list_atoms
.append(AtomPropExport(name
, location
))
47 pdb_file_p
= open(filepath_pdb
, "w")
48 pdb_file_p
.write("REMARK This pdb file has been created with Blender "
49 "and the addon Atomic Blender - PDB\n"
50 "REMARK For more details see the wiki pages of Blender.\n"
54 for i
, atom
in enumerate(list_atoms
):
55 string
= "ATOM %6d%3s%24.3f%8.3f%8.3f%6.2f%6.2f%12s\n" % (
60 1.00, 1.00, atom
.element
)
61 pdb_file_p
.write(string
)