Doghouse DXF with Insulation and Bluetooth

This Python snippet demonstrates how to generate a DXF file for a doghouse with dimensions specified in millimeters. It includes provisions for sound insulation and hints at Bluetooth connectivity.
mail@pastecode.io avatar
unknown
python
12 days ago
2.5 kB
0
Indexable
Never
```python
import ezdxf
import math

def create_doghouse_dxf(filename, width, depth, height):
    # Creare un nuovo documento DXF
    doc = ezdxf.new('R2010')
    msp = doc.modelspace()

    # Definire le dimensioni in mm
    w, d, h = width, depth, height
    wall_thickness = 50  # Spessore della parete per l'insonorizzazione

    # Creare il pavimento con insonorizzazione
    msp.add_rectangle((0, 0), (w, d))
    msp.add_rectangle((wall_thickness, wall_thickness), (w-wall_thickness, d-wall_thickness))
    
    # Creare le pareti con insonorizzazione
    for x, y in [(0, 0), (0, d), (w, 0), (w, d)]:
        msp.add_rectangle((x, y), (wall_thickness, h))
    msp.add_rectangle((0, 0), (w, wall_thickness))
    msp.add_rectangle((0, d-wall_thickness), (w, wall_thickness))

    # Creare il tetto con insonorizzazione
    msp.add_rectangle((0, 0), (w, d)).translate(0, 0, h)
    msp.add_rectangle((wall_thickness, wall_thickness), (w-wall_thickness, d-wall_thickness)).translate(0, 0, h-wall_thickness)

    # Creare la porta (rettangolo trasparente)
    door_width, door_height = w * 0.6, h * 0.8
    door_x = (w - door_width) / 2
    door_y = 0
    msp.add_rectangle((door_x, door_y), (door_width, door_height))

    # Aggiungere simboli per gli altoparlanti
    speaker_radius = 50
    msp.add_circle((speaker_radius+wall_thickness, speaker_radius+wall_thickness, h-wall_thickness-speaker_radius), speaker_radius)
    msp.add_circle((w-speaker_radius-wall_thickness, speaker_radius+wall_thickness, h-wall_thickness-speaker_radius), speaker_radius)

    # Aggiungere una linea per la striscia LED
    msp.add_line((0.1*w, 0.1*d, h-wall_thickness-10), (0.9*w, 0.9*d, h-wall_thickness-10))

    # Aggiungere simbolo per il modulo Bluetooth
    bluetooth_size = 30
    msp.add_rectangle((w-wall_thickness-bluetooth_size, d-wall_thickness-bluetooth_size, h/2), 
                      (bluetooth_size, bluetooth_size))

    # Aggiungere testo per le dimensioni
    msp.add_text(f"{w}mm", dxfattribs={'height': 100}).set_pos((w/2, -200))
    msp.add_text(f"{d}mm", dxfattribs={'height': 100}).set_pos((-200, d/2), align='CENTER').rotate_z(90, (-200, d/2))
    msp.add_text(f"{h}mm", dxfattribs={'height': 100}).set_pos((w+200, h/2), align='CENTER').rotate_z(90, (w+200, h/2))

    # Salvare il file DXF
    doc.saveas(filename)

# Usare la funzione con dimensioni in mm
create_doghouse_dxf('cuccia_insonorizzata_dettagliata.dxf', 1500, 1500, 1800)
```
Leave a Comment