Untitled

mail@pastecode.io avatar
unknown
python
12 days ago
2.4 kB
1
Indexable
Never
import ezdxf

# Definizione delle dimensioni in mm
width = 1500  # larghezza
depth = 1500  # profondità
height = 1800  # altezza

# 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, 0), (width, depth), (0, depth), (0, 0)], dxfattribs={'layer': 'DogHouse'})

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

# Parete posteriore
msp.add_lwpolyline([(0, depth), (0, depth + height)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(width, depth), (width, depth + height)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(0, depth + height), (width, depth + height)], dxfattribs={'layer': 'DogHouse'})

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

# Parete destra
msp.add_lwpolyline([(width, 0), (width, depth)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(width, depth), (width, depth + height)], dxfattribs={'layer': 'DogHouse'})
msp.add_lwpolyline([(width, depth + height), (width, height)], dxfattribs={'layer': 'DogHouse'})

# Creazione del soffitto
msp.add_lwpolyline([(0, height), (width, height), (width, depth + height), (0, depth + height), (0, height)], dxfattribs={'layer': 'DogHouse'})

# Aggiunta della porta (plexiglass trasparente)
door_width = 600  # mm
door_height = 1000  # mm
door_x = (width - 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}")