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
.xyz_import
import ELEMENTS_DEFAULT
23 class AtomsExport(object):
24 __slots__
= ('element', 'location')
25 def __init__(self
, element
, location
):
26 self
.element
= element
27 self
.location
= location
30 def export_xyz(obj_type
, filepath_xyz
):
34 for obj
in bpy
.context
.selected_objects
:
36 if "STICK" in obj
.name
.upper():
39 if obj
.type not in {'MESH', 'SURFACE', 'META'}:
43 for element
in ELEMENTS_DEFAULT
:
44 if element
[1] in obj
.name
:
45 if element
[2] == "Vac":
56 if len(obj
.children
) != 0:
57 for vertex
in obj
.data
.vertices
:
58 location
= obj
.matrix_world
@ vertex
.co
59 list_atoms
.append(AtomsExport(name
, location
))
63 location
= obj
.location
64 list_atoms
.append(AtomsExport(name
, location
))
67 xyz_file_p
= open(filepath_xyz
, "w")
68 xyz_file_p
.write("%d\n" % counter
)
69 xyz_file_p
.write("This XYZ file has been created with Blender "
70 "and the addon Atomic Blender - XYZ. "
71 "For more details see the wiki pages of Blender.\n")
73 for i
, atom
in enumerate(list_atoms
):
74 string
= "%3s%15.5f%15.5f%15.5f\n" % (
79 xyz_file_p
.write(string
)