Posts

Showing posts from May, 2026

Day 14 – Basic Classes and Objects

Image
  ๐Ÿ—️ Day 14 – Basic Classes and Objects 1. Learning Objectives By the end of Day 14, you will be able to: Understand the difference between a class (blueprint) and an object (instance). Define your own classes with attributes (data) and methods (functions). Use the special __init__ method to initialise objects with custom data. Create multiple instances representing real AEC elements (beams, rooms, columns). Write a __str__ method to control how objects are printed. Organise related data and behaviour together – the foundation of Object‑Oriented Programming. 2. Concept Explanation 2.1 Why OOP in AEC? In the built environment, we naturally think in terms of objects: A beam has a span, load, depth, and can compute its moment and deflection. A room has length, width, height, and can compute its area and volume. A building contains a list of floors, each with its own properties. OOP lets you model these real‑world entities directly in code. Instead of scat...

Day 13 – Working with Geometry: numpy & matplotlib

Image
  ๐Ÿ“ Day 13 – Working with Geometry: numpy & matplotlib 1. Learning Objectives By the end of Day 13, you will be able to: Use numpy to create and manipulate arrays of coordinates efficiently. Compute distances, centroids, and transformations (translation, rotation) using numpy. Use matplotlib to create 2D plots of column grids, floor plans, and structural node diagrams. Visualise simple engineering data like beam deflection curves. Save plots as image files for reports. 2. Concept Explanation 2.1 Why numpy & matplotlib in AEC? numpy provides fast, vectorised operations on arrays – essential when working with thousands of coordinates (point clouds, mesh vertices, column grids). matplotlib is the standard Python plotting library. Use it to: Plot column grids and floor plans. Visualise deflection shapes, stress contours, or temperature distributions. Create publication‑ready figures for reports. 2.2 numpy Basics import numpy as np # Creating ar...

Day 12 – Modules, Packages, and Virtual Environments

Image
 ๐Ÿ“ฆ Day 12 – Modules, Packages, and Virtual Environments 1. Learning Objectives By the end of Day 12, you will be able to: Organise your AEC functions into reusable modules ( .py files). Create a package with __init__.py (e.g., an aec_utils package). Use import to bring in your own code and third‑party libraries. Set up virtual environments to manage dependencies for different projects. Build a small, importable library of AEC unit conversions and section properties that you can reuse across projects. 2. Concept Explanation 2.1 Why Modules and Packages? As your scripts grow, keeping everything in one file becomes unmanageable. Modules let you: Organise related functions (e.g., all beam calculations in one file, all material properties in another). Reuse code across multiple projects without copy‑pasting. Share your utilities with colleagues. Namespace – avoid name clashes (two modules can have functions with the same name). 2.2 Creating a Module A ...

Day 11 – List Comprehensions, Lambda, map/filter

Image
  ⚡ Day 11 – List Comprehensions, Lambda, map/filter 1. Learning Objectives By the end of Day 11, you will be able to: Write concise list comprehensions to create and filter lists in a single line. Use dictionary comprehensions and set comprehensions for similar tasks. Create anonymous functions with lambda . Apply map() and filter() for functional‑style data processing. Choose between comprehensions and map / filter for AEC tasks (e.g., filtering beams longer than 6 m, converting all lengths to mm, extracting unique material names). 2. Concept Explanation 2.1 List Comprehensions A list comprehension provides a compact way to create a list by applying an expression to each item in an iterable, optionally with a filtering condition. Syntax: [expression for item in iterable if condition] Traditional loop vs. comprehension: # Traditional loop squares = [] for x in range(10): squares.append(x**2) # List comprehension (one line) squares = [x**2 for x in ran...

Day 10 – Exception Handling and Debugging

Image
  ๐Ÿž Day 10 – Exception Handling and Debugging 1. Learning Objectives By the end of Day 10, you will be able to: Use try / except / else / finally blocks to handle runtime errors gracefully. Handle specific exception types ( FileNotFoundError , ValueError , ZeroDivisionError , KeyError ). Write robust code that doesn’t crash on messy input data or missing files. Use basic debugging techniques: print() debugging, reading tracebacks, and using pdb . Apply exception handling to real AEC scenarios (missing spreadsheet cells, division by zero in calculations, file import errors). 2. Concept Explanation 2.1 What Are Exceptions? Exceptions are errors that occur during program execution. When an exception is not handled, the program crashes with a traceback. Common AEC exceptions: Exception Common Cause in AEC FileNotFoundError Trying to open a CSV/Excel file that doesn’t exist ValueError User enters text where a number is expected ZeroDivisionError Dividing by zero ...

Day 9 – File Handling and Data I/O (CSV, TXT, Excel)

Image
 ๐Ÿ“ Day 9 – File Handling and Data I/O (CSV, TXT, Excel) 1. Learning Objectives By the end of Day 9, you will be able to: Open, read, and write plain text files ( .txt ) using Python’s built‑in open() . Read and write CSV files (comma‑separated values) using the csv module. Use pandas to read and write Excel ( .xlsx ) and CSV files. Process AEC data from external files: structural member schedules, material take‑offs, coordinate lists. Write formatted reports and export results for use in spreadsheets or BIM tools. 2. Concept Explanation 2.1 Why File I/O Matters in AEC In practice, you rarely type data directly into a Python script. Instead you: Import a beam schedule from Excel to perform design checks. Read a CSV of column coordinates exported from CAD. Write a material quantity report to share with a quantity surveyor. Parse a text‑based model export from a structural analysis tool. File I/O bridges Python and your existing project data. 2.2 Reading...

Day 8 – String Manipulation and Formatting

Image
 ๐Ÿงต Day 8 – String Manipulation and Formatting 1. Learning Objectives By the end of Day 8, you will be able to: Use common string methods ( .upper() , .lower() , .strip() , .split() , .join() , .replace() , .find() , .startswith() ). Format strings using f‑strings, .format() , and % ‑formatting. Generate formatted reports (e.g., material take‑offs, beam schedules). Work with part marks, drawing numbers, and naming conventions. Clean and standardise user‑input strings for robust AEC scripts. 2. Concept Explanation 2.1 Why Strings Matter in AEC Strings are everywhere in AEC practice: Drawing numbers: "A-101" , "S-202-RevB" Material names: "Concrete C30" , "Steel Grade 355" Part marks: "UB 406×178×60" , "B1" , "COL-12" Project codes: "PROJ-2026-045" User input that needs cleaning (e.g., " Concrete " → "Concrete" ) Being able to manipulate and format strings is...
EARN AT THE COMFORT OF YOUR HOME

Sponsored content