# spiral made of words/text using bpy

im looking for some help on using the code (already working blender 2.9.2) to trace/create a column using a .txt file providing a list of words. Around 100 words.

Ideally the words should create a spiral like this one:

No need to have a visible spiral structure, floating words suspended should be ideal.

So far I have this code:

import bpy

f = open("/Users/sust.txt", "r")

y=0
x=0
z=0

for line in f:

t1 = bpy.data.curves.new("message", "FONT")
o1 = bpy.data.objects.new("message", t1)
o1.location = (x,y,z)
t1.body = line
t1.offset_x = 0.1
t1.offset_y = -0.25
t1.shear = -0.5

t1.extrude = 0.4

x = x - .05*t1.size
y = y - -5*t1.size
z = z - .05*t1.size


The code above traces a slanted column of words taken from the sust.txt file

Any hints or help appreciated!

• and how should the words be placed along the spiral object..? here's a basic option with Geometry Nodes, I used Edit > Text to 3d Object to populate a collection from a text editor window... Apr 17 at 23:02
• Thanks for answering. Unfortunately I cant open the file. Blender 2.9 here tells me file type not supported. Apr 18 at 0:11
• that's because it's a 3.1 file... see you can have both versions installed if you don't want to update yet... and you can do it with code, here i changed your file but miss the resample node that helps keep distance constant between words... i somehow compensated for the vertices being too close in the narrow part of spiral, you need to play with values... it's a 2.93 blend Apr 18 at 14:18
• I would 1) create a spiral with the curves extra objects add-on. 2) Read the entire text file into a single string and use it as the text for a Text object. 3) add a curve modifier to the text object. 4) Hide the spiral from view and from render. If that would work, I can write code to do it. Apr 18 at 14:45

If you want your spiral object to look something like this:

You can use the code below.

It uses a built-in add-on, "Add Curve: Extra Objects", so be sure that's enabled.

Step by step, the code

• reads the text from the file, creating a single long string, replacing the new line characters from the file with spaces. (I didn't bother to remove the final trailing space, but that's easy enough to do.)

• creates a spiral curve. The arguments for this are not well documented, so to get the settings you want, I recommend creating a spiral curve by hand, playing with the last operate adjust panel to see what the parameters are and modifying my call to bpy.ops.curve.spirals with the arguments that suit your needs.

• hides the spiral curve from both the viewport and the render.

• creates the text curve, and effectively rotates it 180 degrees on the Y axis so it won't look like a mirror image.

• sets the text of the curve object to the string from the file.

• adds the modifier to the text object and sets it to follow the spiral curve.

• It sets the text of the text curve to the string read from the file.

import bpy

# Read the file into a string
file = PATH_TO_FILE_CONTAINING_TEXT

def file_to_text(filename):
with open(filename, 'r') as f:
return contents
string = file_to_text(file)

# Create the spiral
curve_object = bpy.data.objects['Spiral']

# Hide it
curve_object.hide_viewport = True
curve_object.hide_render = True

# Create the text object
text_object = bpy.data.objects['Text']
text_object.scale=(1,-1,1)

# Set the text to the string from the file
text_curve = text_object.data
text_curve.body = string

# Add the curve modifier and set it to use the spiral
text_object.modifiers.new('curve', 'CURVE')
curve_modifier = text_object.modifiers[-1]
curve_modifier.object = curve_object

• Hey Marty, thanks for your code and help! It works here, I have just to fine tune the turns of elevation and put shorter words or just puntuation marks at the very beginning of the .txt file to avoid getting jammed words at the start of the spiral. Apr 18 at 18:02
• @funkz you're welcome. Glad I cold help. Apr 18 at 22:08