Cuccia

mail@pastecode.io avatar
unknown
python
11 days ago
2.9 kB
3
Indexable
Never
import ezdxf

# Funzione per convertire cm in pollici
def cm_to_inch(cm):
    return cm / 2.54

# Definizione delle dimensioni in cm
width = 150  # larghezza
depth = 150  # profondità
height = 180  # altezza

# Conversione delle dimensioni in pollici
width_inch = cm_to_inch(width)
depth_inch = cm_to_inch(depth)
height_inch = cm_to_inch(height)

# Creazione di un nuovo documento DXF
doc = ezdxf.new(dxfversion='R2010')

# Aggiunta di un nuovo layer per la cuccia
doc.layers.add(name='DogHouse', color=1)

# Creazione della base (pavimento)
msp = doc.modelspace()
msp.add_lwpolyline([(0, 0), (width_inch, 0), (width_inch, depth_inch), (0, depth_inch), (0, 0)], dxfattribs={'layer': 'DogHouse'})

# Creazione delle pareti
# Parete anteriore
msp.add_lwpolyline([(0, 0), (0, height_inch)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(width_inch, 0), (width_inch, height_inch)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(0, height_inch), (width_inch, height_inch)], dxfattribs={'layer': 'DogHouse'})

# Parete posteriore
msp.add_lwpolyline([(0, depth_inch), (0, depth_inch + height_inch)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(width_inch, depth_inch), (width_inch, depth_inch + height_inch)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(0, depth_inch + height_inch), (width_inch, depth_inch + height_inch)], dxfattribs={'layer': 'DogHouse'})

# Parete sinistra
msp.add_lwpolyline([(0, 0), (0, depth_inch)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(0, depth_inch), (0, depth_inch + height_inch)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(0, depth_inch + height_inch), (0, height_inch)], dxfattribs={'layer': 'DogHouse'})

# Parete destra
msp.add_lwpolyline([(width_inch, 0), (width_inch, depth_inch)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(width_inch, depth_inch), (width_inch, depth_inch + height_inch)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(width_inch, depth_inch + height_inch), (width_inch, height_inch)], dxfattribs={'layer': 'DogHouse'})

# Creazione del soffitto
msp.add_lwpolyline([(0, height_inch), (width_inch, height_inch), (width_inch, depth_inch + height_inch), (0, depth_inch + height_inch), (0, height_inch)], dxfattribs={'layer': 'DogHouse'})

# Aggiunta della porta (plexiglass trasparente)
door_width = cm_to_inch(60)  # cm
door_height = cm_to_inch(100)  # cm
door_x = (width_inch - door_width) / 2
msp.add_lwpolyline([(door_x, 0), (door_x, door_height)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(door_x + door_width, 0), (door_x + door_width, door_height)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(door_x, door_height), (door_x + door_width, door_height)], dxfattribs={'layer': 'DogHouse'})

# Salvataggio del file DXF
file_path = 'dog_house_project.dwg'
doc.saveas(file_path)

print(f"File salvato in {file_path}")
Leave a Comment