import cadquery as cq
from cadquery import exporters

import gantry

parts = [
    (gantry.g.upper_front_plate, "gantry_upper_front", gantry.plate_z),
    (gantry.g.upper_back_plate, "gantry_upper_back", gantry.plate_z),
    (gantry.g.lower_front_plate, "gantry_lower_front", gantry.plate_z),
    (gantry.g.lower_back_plate, "gantry_lower_back", gantry.plate_z),
    (gantry.g.right_bearing_mount, "gantry_fixed_bearing_mount", gantry.x_mount_z),
    (gantry.g.left_bearing_mount, "gantry_floating_bearing_mount", gantry.x_mount_z),
    (gantry.g.stepper_mount, "gantry_stepper_mount", gantry.stepper_mount_z),
    (gantry.c.plate, "carriage", gantry.plate_z2),
    (gantry.ca.plate, "carrier", gantry.carrier_plate_z),
    (gantry.ca.left_spacer, "carrier_left_spacer", gantry.z_spacer_z),
    (gantry.ca.right_spacer, "carrier_right_spacer", gantry.z_spacer_z),
    (gantry.ca.stepper_mount, "carrier_stepper_mount", gantry.stepper_mount_z),
    (gantry.g.combined_front_plate, "combined_upper_front", gantry.plate_z),
]

for part, path, thickness in parts:
    exporters.exportDXF(
        part.workplaneFromTagged("base").section(0.1),
        "dxfs/{}-{:.2f}mm.dxf".format(path, thickness),
    )
