Blender as Electic-Fields visualizer

Over the days I wrote a little script which calculates the FieldLines of a charged mesh’s volume.


  • Add charges to the Object as a Particle System
    (Every Partice represents a point charge)
  • Reconfigure Parameters of the script (charge and numSegments are the important ones)
  • Run Script
  • Get great results !

Todo: - Multible Particels as Field influence
- Make the whole thing animatable
- Positive charges

Have fun and let me see what you’re doing with it.

Demo Model Twisted Torus with FieldLines:



import bpy,math
from mathutils import Vector

charge = 0.0001
numSegments = 250
w = 1

#get the first selected Object
object = bpy.context.selected_objects[0]

#get the charges in the Volume of the mesh (=Input)
charges = object.particle_systems[0].particles

#so for each “line” do the pyhisics calulation
for j, v in enumerate(
#for each segment of the line calculate the points for
#the field lines

#generate the resulting fieldline-curve
fieldline =

fieldline.dimensions = '3D'

polyline ='POLY')  

#print the current progress of the calculations (how many fieldLines are
#already generated)

for i in range(numSegments):
    if(i == 0):
        #get the starting point of each fieldLine for easier access
        x =
        y =
        z =
        #calculate the resulting field-vector by superposition(=Sum)
        #of the charge's force at the current point
        fx = 0
        fy = 0
        fz = 0
        for c in charges:
            #Get the current vector which connects our fieldLines's point
            #with the current charge (From charge To point -> (From - To))
            dx = x - c.location.x
            dy = y - c.location.y
            dz = z - c.location.z
            r = math.sqrt(dx*dx+dy*dy+dz*dz)
            fx += charge * (dx / (r*r*r)) 
            fy += charge * (dy / (r*r*r)) 
            fz += charge * (dz / (r*r*r))
        x += fx
        y += fy
        z += fz
    #add the fieldline's vertices to our calculated result
    polyline.points[i].co = (x, y, z, w)

#paste the existing pydata into the object
objectdata ="FieldLine"+str(j), fieldline)  
objectdata.location = (0,0,0) #object origin

Plz. move Thread to Blender-Scripts !