Есть рабочий файл, при экспорте точек координат, из блендеровских не меняется XZY  координаты в XYZ, хотя должны. В коде указан конвентор, не могу понять , в чем дело? 

import bpy
import os
import xml.etree.ElementTree as ET
from bpy_extras.io_utils import ImportHelper, ExportHelper

bl_info = {
    "name": "F1 AI Track Layout Maker",
    "author": "AlonsoBeast",
    "version": (1, 0),
    "blender": (3, 3, 0),
    "description": "Import and export F1 track layout from XML files",
    "category": "Object",
}

# Global variable to store gate empty objects for easy access
gate_objects = []
previous_positions = []  # Для хранения предыдущих позиций
original_file_path = ""  # Для хранения пути к импортированному файлу

class F1AITrackLayoutMakerPanel(bpy.types.Panel):
    bl_label = "F1 Track Builder Toolkit"
    bl_idname = "OBJECT_PT_f1_track_builder_toolkit"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'F1 Track'

    def draw(self, context):
        layout = self.layout
        layout.operator(ImportF1TrackLayout.bl_idname, text="Import F1 Track Layout")
        layout.operator(ExportF1TrackLayout.bl_idname, text="Export F1 Track Layout")
        layout.operator(UpdateGatePositions.bl_idname, text="Update Gates")  # Кнопка для обновления позиций

        # Проверка, есть ли объект кривой
        if "F1_Track" in bpy.data.objects:
            curve_object = bpy.data.objects["F1_Track"]
            control_points = curve_object.data.splines[0].bezier_points
            
            # Выделенные контрольные точки
            selected_points = [point for point in control_points if point.select_control_point]
            
            # Вывод темного фона для выделенных контрольных точек
            layout.label(text="Selected Control Points", icon='OBJECT_DATA')
            
            # Добавление контейнера для имен и координат выделенных точек
            box = layout.box()
            for point in selected_points:
                gate_number = point.get("gate_number", None)
                if gate_number is not None:
                    gate_name = f"gate_{gate_number:02}"  # Форматирование имени gate
                    box.label(text=f"{gate_name}", icon='OBJECT_DATA')
                    box.label(text=f"<Vector {point.co}>")

class ImportF1TrackLayout(bpy.types.Operator, ImportHelper):
    bl_idname = "import.f1_track_layout"
    bl_label = "Import F1 Track Layout"
    filename_ext = ".xml"

    def execute(self, context):
        global previous_positions, original_file_path  # Объявляем глобальные переменные
        original_file_path = self.filepath  # Сохраняем путь к оригинальному файлу

        if not os.path.isfile(original_file_path):
            self.report({'ERROR'}, "File does not exist.")
            return {'CANCELLED'}

        # Reset previous positions
        previous_positions.clear()

        # Parse XML file
        try:
            tree = ET.parse(original_file_path)
            root = tree.getroot()
        except ET.ParseError as e:
            self.report({'ERROR'}, f"XML parse error: {e}")
            return {'CANCELLED'}

        # Correct path to find gates
        gates = root.find('.//gates').findall('gate')

        if not gates:
            self.report({'ERROR'}, "No gates found in the XML file.")
            return {'CANCELLED'}

        # Create new Bezier curve for the track
        curve_data = bpy.data.curves.new(name="F1_Track_Curve", type='CURVE')
        curve_data.dimensions = '3D'
        spline = curve_data.splines.new('BEZIER')

        # Check existing gate objects
        gate_objects.clear()  # Очистка списка перед заполнением
        for obj in bpy.context.collection.objects:
            if "gate_" in obj.name:
                gate_objects.append(obj)

        # Create control points
        spline.bezier_points.add(len(gates) - 1)

        for i, gate in enumerate(gates):
            position = gate.find('position')
            if position is not None:
                # Parsing coordinates
                x, z, y = map(float, position.text.split())  # Импортируем как X, Y, Z
                # Set the location of control point (Blender uses XZY)
                control_point = spline.bezier_points[i]
                control_point.co = (x, y, z)  # Установка координат в Blender (X, Y, Z)
                control_point.handle_left_type = 'VECTOR'
                control_point.handle_right_type = 'VECTOR'

                # If gate empty already exists, update its location
                if i < len(gate_objects):
                    gate_empty = gate_objects[i]
                    gate_empty.location = (x, y, z)
                else:
                    # Create a new empty if it doesn't exist
                    gate_empty = bpy.data.objects.new(f"gate_{i:02}", None)
                    gate_empty.empty_display_type = 'CUBE'
                    gate_empty.empty_display_size = 0.5
                    gate_empty.location = (x, y, z)
                    gate_empty["gate_number"] = i
                    context.collection.objects.link(gate_empty)
                    gate_objects.append(gate_empty)

                # Save the position for comparison
                previous_positions.append(control_point.co.copy())

        # Create a new object for the Bezier curve
        curve_object = bpy.data.objects.new("F1_Track", curve_data)
        context.collection.objects.link(curve_object)

        # Set the active object to the newly created one
        bpy.context.view_layer.objects.active = curve_object
        curve_object.select_set(True)

        self.report({'INFO'}, f"Successfully imported {len(gates)} gates.")
        return {'FINISHED'}

class ExportF1TrackLayout(bpy.types.Operator, ExportHelper):
    bl_idname = "export.f1_track_layout"
    bl_label = "Export F1 Track Layout"
    filename_ext = ".xml"

    def execute(self, context):
        global original_file_path  # Используем глобальную переменную для сохранения пути
        
        if not original_file_path:
            self.report({'ERROR'}, "Please import the track layout first.")
            return {'CANCELLED'}

        # Load original XML to preserve its structure
        try:
            tree = ET.parse(original_file_path)
            root = tree.getroot()
        except ET.ParseError as e:
            self.report({'ERROR'}, f"XML parse error: {e}")
            return {'CANCELLED'}

        # Ensure there's a curve to export
        if "F1_Track" not in bpy.data.objects:
            self.report({'ERROR'}, "No F1 Track Curve found.")
            return {'CANCELLED'}

        curve = bpy.data.objects["F1_Track"]
        control_points = curve.data.splines[0].bezier_points

        # Update positions in the original XML structure
        gates = root.find('.//gates').findall('gate')
        for i, control_point in enumerate(control_points):
            if i < len(gates):
                position = gates[i].find('position')
                if position is not None:
                    # Обновление позиции с новыми координатами (переводом XZY в XYZ)
                    position.text = f"{round(control_point.co.x, 2)} {round(control_point.co.y, 2)} {round(control_point.co.z, 2)}"

        # Создаем новый файл для экспортирования с новым именем
        export_filepath = os.path.splitext(original_file_path)[0] + "_modified.xml"  # Создаем дубликат
        tree.write(export_filepath)

        self.report({'INFO'}, f"Successfully exported track layout to: {export_filepath}")
        return {'FINISHED'}

class UpdateGatePositions(bpy.types.Operator):
    """Update gate positions based on the Bezier control points"""
    bl_idname = "object.update_gate_positions"
    bl_label = "Update Gate Positions"

    @classmethod
    def poll(cls, context):
        return "F1_Track" in bpy.data.objects

    def execute(self, context):
        global previous_positions
        curve_object = bpy.data.objects["F1_Track"]
        control_points = curve_object.data.splines[0].bezier_points

        for i, point in enumerate(control_points):
            # Проверка существования пустышки
            if i < len(gate_objects):
                gate_empty = gate_objects[i]
                
                # Проверка, не был ли удален gate_empty
                if gate_empty.name not in bpy.data.objects:
                    # Создаем новую пустышку, если она была удалена
                    gate_empty = bpy.data.objects.new(f"gate_{i:02}", None)
                    gate_empty.empty_display_type = 'CUBE'
                    gate_empty.empty_display_size = 0.5
                    gate_empty.location = (point.co.x, point.co.y, point.co.z)
                    gate_empty["gate_number"] = i
                    context.collection.objects.link(gate_empty)
                    gate_objects.append(gate_empty)  # Обновляем ссылку на пустышку
                else:
                    # Обновляем положение пустышек
                    gate_empty.location = (point.co.x, point.co.y, point.co.z)

        # Обновление предыдущих позиций
        previous_positions = [point.co.copy() for point in control_points]

        return {'FINISHED'}

def register():
    bpy.utils.register_class(F1AITrackLayoutMakerPanel)
    bpy.utils.register_class(ImportF1TrackLayout)
    bpy.utils.register_class(ExportF1TrackLayout)
    bpy.utils.register_class(UpdateGatePositions)

def unregister():
    bpy.utils.unregister_class(F1AITrackLayoutMakerPanel)
    bpy.utils.unregister_class(ImportF1TrackLayout)
    bpy.utils.unregister_class(ExportF1TrackLayout)
    bpy.utils.unregister_class(UpdateGatePositions)

if __name__ == "__main__":
    register()