---
title: Tutorial 38 Generative Design for FDM
description: Growing structures that respect gravity.
---
Tutorial 38 Generative Design for FDM
1. Lesson Header
- Lesson Number: 38
- Level: Master
- Title: Generative Design for FDM
- Estimated Duration: 60 Minutes
- Prerequisites: Lesson 34 (Infill), Lesson 23 (Bridging)
- What You Will Build: A "Tree Support" Generator.
2. Concept Introduction
The Support Problem.
Standard supports are wasteful.
Tree Supports grow from the base and branch out to touch overhangs only where needed.
This is Generative Design: The algorithm "grows" the geometry based on constraints.
Constraint 1: Must support the overhang.
Constraint 2: Must be printable (Max angle 45 degrees).
3. Machine State Explanation
Growth Algorithm.
Start at the Overhang Point (Target).
Grow downwards towards the build plate (Source).
At each step dz, move dx, dy such that sqrt(dx^2 + dy^2) <= dz * tan(45).
Avoid collisions with the model.
Merge branches if they get close.
4. Command Breakdown
- Path Planning: Finding a route from A to B in 3D space with obstacles.
- *Dijkstra / A:** Algorithms for shortest path.
5. Minimal Working Example
The Single Branch.
Target: (10, 10, 50). Base: (0, 0, 0).
Path: A straight line.
Angle: atan(sqrt(10^2+10^2)/50) = 15 degrees. Safe!
6. Visual Representation
Interactive preview is available in the interactive reader.
7. Build Exercise
Task: Write a Python script to generate a simple tree support for a floating point P(50, 50, 50).
The base is at Z=0.
The trunk must dodge a "Blocker" cylinder at (25, 25) with Radius 10.
Algorithm:
1. Discretize space (grid).
2. Mark blocker cells as "Obstacle".
3. Run A* search from Target to Z=0 plane.
4. Cost = Distance + Penalty for steep angles.
5. Convert path to G-code (concentric circles along the path).
8. Deep Insight Section
Topology Optimization.
Instead of just supports, we can optimize the part itself.
"Remove material where stress is low."
For FDM, we add a constraint: "Ensure remaining material is self-supporting."
This creates organic, bone-like structures that need no support at all.
9. Common Failure Modes
- Thin Branches: A single-wall branch 100mm tall is wobbly.
- Base Adhesion: The tiny footprint of a tree trunk might detach. Add a brim!
10. Real-World Application
Aerospace Brackets.
GE prints fuel nozzles and brackets that are topologically optimized.
They save 50% weight.
The design software (nTopology) ensures the complex organic shapes are printable.
11. Final Clean Version
The Tree Generator (Conceptual):
import math
target = (50, 50, 50)
base_z = 0
current_pos = list(target)
path = [tuple(current_pos)]
# Simple "Direct" path logic (no obstacles)
while current_pos[2] > base_z:
# Move down
current_pos[2] -= 0.2 # Layer height
# Move XY towards base (0,0) slightly
# But limit angle to 45 deg max
# dx, dy towards 0,0
angle = math.atan2(0 - current_pos[1], 0 - current_pos[0])
max_step = 0.2 * math.tan(math.radians(45))
current_pos[0] += max_step * math.cos(angle)
current_pos[1] += max_step * math.sin(angle)
path.append(tuple(current_pos))
# Convert path to G-code cylinders
with open("tree.gcode", "w") as f:
f.write("G28\n")
for p in reversed(path): # Print from bottom up
x, y, z = p
# Draw a small circle at x,y,z
f.write(f"G1 Z{z} F9000\n")
f.write(f"G1 X{x+2} Y{y} E... F1000\n")
# ... full circle logic ...
12. Stretch Challenge
Challenge: Implement Branch Merging.
Generate supports for TWO points: (10,10,50) and (-10,-10,50).
Grow them downwards.
When they get close enough, merge them into a single trunk to save material.
Hint: This looks like a 'Y' shape upside down.