1 # SPDX-License-Identifier: GPL-2.0-or-later
4 from io_mesh_atomic
.xyz_import
import ELEMENTS_DEFAULT
7 class AtomsExport(object):
8 __slots__
= ('element', 'location')
9 def __init__(self
, element
, location
):
10 self
.element
= element
11 self
.location
= location
14 def export_xyz(obj_type
, filepath_xyz
):
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(AtomsExport(name
, location
))
47 location
= obj
.location
48 list_atoms
.append(AtomsExport(name
, location
))
51 xyz_file_p
= open(filepath_xyz
, "w")
52 xyz_file_p
.write("%d\n" % counter
)
53 xyz_file_p
.write("This XYZ file has been created with Blender "
54 "and the addon Atomic Blender - XYZ. "
55 "For more details see the wiki pages of Blender.\n")
57 for i
, atom
in enumerate(list_atoms
):
58 string
= "%3s%15.5f%15.5f%15.5f\n" % (
63 xyz_file_p
.write(string
)