1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from io_mesh_atomic
.xyz_import
import ELEMENTS_DEFAULT
9 class AtomsExport(object):
10 __slots__
= ('element', 'location')
11 def __init__(self
, element
, location
):
12 self
.element
= element
13 self
.location
= location
16 def export_xyz(obj_type
, filepath_xyz
):
20 for obj
in bpy
.context
.selected_objects
:
22 if "STICK" in obj
.name
.upper():
25 if obj
.type not in {'MESH', 'SURFACE', 'META'}:
29 for element
in ELEMENTS_DEFAULT
:
30 if element
[1] in obj
.name
:
31 if element
[2] == "Vac":
42 if len(obj
.children
) != 0:
43 for vertex
in obj
.data
.vertices
:
44 location
= obj
.matrix_world
@ vertex
.co
45 list_atoms
.append(AtomsExport(name
, location
))
49 location
= obj
.location
50 list_atoms
.append(AtomsExport(name
, location
))
53 xyz_file_p
= open(filepath_xyz
, "w")
54 xyz_file_p
.write("%d\n" % counter
)
55 xyz_file_p
.write("This XYZ file has been created with Blender "
56 "and the addon Atomic Blender - XYZ. "
57 "For more details see the wiki pages of Blender.\n")
59 for i
, atom
in enumerate(list_atoms
):
60 string
= "%3s%15.5f%15.5f%15.5f\n" % (
65 xyz_file_p
.write(string
)