1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from io_mesh_atomic
.pdb_import
import ELEMENTS_DEFAULT
8 class AtomPropExport(object):
9 __slots__
= ('element', 'location')
10 def __init__(self
, element
, location
):
11 self
.element
= element
12 self
.location
= location
15 def export_pdb(obj_type
, filepath_pdb
):
18 for obj
in bpy
.context
.selected_objects
:
20 if "STICK" in obj
.name
.upper():
23 if obj
.type not in {'MESH', 'SURFACE', 'META'}:
27 for element
in ELEMENTS_DEFAULT
:
28 if element
[1] in obj
.name
:
29 if element
[2] == "Vac":
40 if len(obj
.children
) != 0:
41 for vertex
in obj
.data
.vertices
:
42 location
= obj
.matrix_world
@ vertex
.co
43 list_atoms
.append(AtomPropExport(name
, location
))
46 location
= obj
.location
47 list_atoms
.append(AtomPropExport(name
, location
))
49 pdb_file_p
= open(filepath_pdb
, "w")
50 pdb_file_p
.write("REMARK This pdb file has been created with Blender "
51 "and the addon Atomic Blender - PDB\n"
52 "REMARK For more details see the wiki pages of Blender.\n"
56 for i
, atom
in enumerate(list_atoms
):
57 string
= "ATOM %6d%3s%24.3f%8.3f%8.3f%6.2f%6.2f%12s\n" % (
62 1.00, 1.00, atom
.element
)
63 pdb_file_p
.write(string
)