import ezdxf
def generate_structural_layout():
# 1. Create a new DXF document (AutoCAD R2010 format)
doc = [Link](dxfversion="R2010")
msp = [Link]()
# 2. Establish organized layer system with standardized colors
[Link](name="STR_COLUMNS", dxfattribs={"color": 1}) # Red
[Link](name="STR_BEAMS", dxfattribs={"color": 5}) # Blue
[Link](name="STR_JOISTS", dxfattribs={"color": 2}) # Yellow
# 3. Structural dimensions in millimeters (Dossier A-101 / S-201)
beam_span = 5000.0 # 5.0 meters primary span
joist_spacing = 610.0 # 2.0 feet center-to-center
col_width = 230.0 # 9 inches width
col_length = 300.0 # 12 inches depth
# 4. Define center anchor points for columns C1 to C5
column_centers = [
(0.0, 0.0), # Corner C1
(beam_span, 0.0), # Corner C2
(0.0, beam_span), # Corner C3
(beam_span, beam_span), # Corner C4
(beam_span / 2.0, beam_span / 2.0) # Central grid intersection C5
]
# 5. Draw RCC Columns as closed polylines
w2 = col_width / 2.0
l2 = col_length / 2.0
for cx, cy in column_centers:
vertices = [
(cx - w2, cy - l2),
(cx + w2, cy - l2),
(cx + w2, cy + l2),
(cx - w2, cy + l2)
]
msp.add_lwpolyline(vertices, close=True, dxfattribs={"layer":
"STR_COLUMNS"})
# 6. Draw Primary Steel Beams
primary_beams = [
((0.0, 0.0), (beam_span, 0.0)),
((0.0, beam_span), (beam_span, beam_span)),
((0.0, 0.0), (0.0, beam_span)),
((beam_span, 0.0), (beam_span, beam_span))
]
for start, end in primary_beams:
msp.add_line(start, end, dxfattribs={"layer": "STR_BEAMS"})
# 7. Generate Parallel Secondary Floor Joists
current_x = joist_spacing
while current_x < beam_span:
msp.add_line(
(current_x, 0.0),
(current_x, beam_span),
dxfattribs={"layer": "STR_JOISTS"}
)
current_x += joist_spacing
# 8. Save output file
output_filename = "structural_layout.dxf"
[Link](output_filename)
print(f"[SUCCESS] Saved drawing to: {output_filename}")
if __name__ == "__main__":
generate_structural_layout()